Magento: get current CMS page ID


/ Published in: PHP
Save to your folder(s)

A function for returning the ID of the current CMS page


Copy this code and paste it in your HTML
  1. /**
  2.  * Returns the identifier for the currently rendered CMS page.
  3.  * If current page is not from CMS, null is returned.
  4.  * @return String | Null
  5.  */
  6. public function getCurrentCmsPage() {
  7. $dataCurrentPage = $this->getHelper('cms/page')->getPage()->getData();
  8. if ($dataCurrentPage) {
  9. $identifierCurrentPage = $dataCurrentPage['identifier'];
  10. return $identifierCurrentPage;
  11. }
  12. return;
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.