A UDT that gets the current page ID (CMSMS 2)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

A UDT that gets the current page ID (CMSMS 2)

Post by Guido »

Create a UDT called 'get_current_page_id':

Code: Select all

$assign = isset($params['assign']) ? $params['assign'] : 'page_id';
$hm = cmsms()->GetHierarchyManager();
if ( empty($page_id) ) $page_id = \cms_utils::get_current_pageid();
$smarty->assignGlobal($assign,$page_id);
Now in your template use:

Code: Select all

{get_current_page_id assign='page_id'}
And you'll have {$page_id} available.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: A UDT that gets the current page ID (CMSMS 2)

Post by calguy1000 »

{$page_id} is built in.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Tips and Tricks”