• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Getting a page's root parent's alias
PostPosted: Sun Sep 17, 2006 12:00 am 
I needed a way to get the alias of a pages very top parent and calguy1000 on the IRC channel assisted me.

The code he has come up with is as follows...

Code:
global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();

$var = 'root_page_alias';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->Alias();
    $currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);


Create a new user-defined tag called get_root_page_alias and copy in the above code.

The tag can be called using...
Code:
{get_root_page_alias assign="varname"}


An example use would be...
Code:
{get_root_page_alias assign="root_page_alias"}The root parent of this page is:{$root_page_alias}


Top
  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Sun Sep 17, 2006 12:39 pm 
Offline
Power Poster
Power Poster

Joined: Sun Mar 19, 2006 8:46 pm
Posts: 1200
Location: the Netherlands
Cool, I added it to the docs/wiki:
http://wiki.cmsmadesimple.org/index.php ... .27s_alias


Top
 Profile  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Wed Sep 27, 2006 9:01 am 
Offline
Forum Members
Forum Members

Joined: Sun Sep 10, 2006 4:14 pm
Posts: 20
This code doesn't work? I have CMSMS version 0.13. When I put the tag into the template code it stop printing after that.


Top
 Profile  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Wed Sep 27, 2006 9:03 am 
Offline
Power Poster
Power Poster

Joined: Sun Mar 19, 2006 8:46 pm
Posts: 1200
Location: the Netherlands
I think this will only work on 1.0.


Top
 Profile  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Wed Sep 27, 2006 9:14 am 
Offline
Forum Members
Forum Members

Joined: Sun Sep 10, 2006 4:14 pm
Posts: 20
Yes, I just noticed the same thing.

So, I made a code which will work in version 0.13.

Code:
global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['content_id'];
$node =& $manager->sureGetNodeById($thisPage);


$node_data = (get_object_vars($node));
$parent_node = (get_object_vars($node_data[parentNode]));
$parent_node_content = (get_object_vars($parent_node[content]));

echo $parent_node_content[mAlias];


This print page's root parent alias.


Last edited by haapati on Wed Sep 27, 2006 11:13 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Tue Nov 14, 2006 1:12 am 
Is it possible to get the root page title?


Top
  
 
 Post subject: Re: Getting a page's root parent's alias
PostPosted: Thu Nov 16, 2006 3:41 pm 
Offline
Power Poster
Power Poster

Joined: Wed Sep 08, 2004 3:32 pm
Posts: 524
Do you mean as a tag or the title-attribute of the root-page? As far as I know you can get the title-attribute if it is set.<br /><br />Regards,<br />Nils</div> <br clear="all" /><br /> <table width="100%" cellspacing="0"> <tr valign="middle"> <td class="gensmall" align="right"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr class="row1"> <td class="profile"><strong><a href="#wrapheader">Top</a></strong></td> <td><div class="gensmall" style="float: left;"> <a href="./memberlist.php?mode=viewprofile&u=20&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/icon_user_profile.gif" alt="Profile" title="Profile" /></a>  </div> <div class="gensmall" style="float: right;"> </div></td> </tr> <tr> <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> </tr> </table> <table class="tablebg" width="100%" cellspacing="1"> <tr class="row2"> <td align="center" valign="middle"> <a name="p42535"></a> <b class="postauthor">ostricized</b> </td> <td width="100%" height="25"> <table width="100%" cellspacing="0"> <tr> <td class="gensmall" width="100%"><div style="float: left;"> <b>Post subject:</b> Re: Getting a page's root parent's alias</div><div style="float: right;"><a href="./viewtopic.php?p=42535&sid=de1d800585e2c62962960de36e270949#p42535"><img src="./styles/subsilver2/imageset/icon_post_target.gif" width="12" height="9" alt="Post" title="Post" /></a><b>Posted:</b> Sun Nov 19, 2006 1:56 am </div></td> </tr> </table> </td> </tr> <tr class="row2"> <td valign="top" class="profile"> <table cellspacing="4" align="center" width="150"> <tr> <td></td> </tr> </table> <span class="postdetails"> </span> </td> <td valign="top"> <table width="100%" cellspacing="5"> <tr> <td> <div class="postbody">Hi Nils73!<br /><br />I am looking for the root page title value (attribute?), more specifically, the magic syntax to obtain that value just like what the 2 examples in this thread accomplish.<br /><br />Thank you very much in advance if anyone is willing to part with this information =)</div> <br clear="all" /><br /> <table width="100%" cellspacing="0"> <tr valign="middle"> <td class="gensmall" align="right"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr class="row2"> <td class="profile"><strong><a href="#wrapheader">Top</a></strong></td> <td><div class="gensmall" style="float: left;">  </div> <div class="gensmall" style="float: right;"> </div></td> </tr> <tr> <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> </tr> </table> <table class="tablebg" width="100%" cellspacing="1"> <tr class="row1"> <td align="center" valign="middle"> <a name="p42554"></a> <b class="postauthor">nils73</b> </td> <td width="100%" height="25"> <table width="100%" cellspacing="0"> <tr> <td class="gensmall" width="100%"><div style="float: left;"> <b>Post subject:</b> Re: Getting a page's root parent's alias</div><div style="float: right;"><a href="./viewtopic.php?p=42554&sid=de1d800585e2c62962960de36e270949#p42554"><img src="./styles/subsilver2/imageset/icon_post_target.gif" width="12" height="9" alt="Post" title="Post" /></a><b>Posted:</b> Sun Nov 19, 2006 2:34 pm </div></td> </tr> </table> </td> </tr> <tr class="row1"> <td valign="top" class="profile"> <table cellspacing="4" align="center" width="150"> <tr> <td><img src="./styles/subsilver2/imageset/en/icon_user_offline.gif" alt="Offline" title="Offline" /></td> </tr> <tr> <td class="postdetails">Power Poster</td> </tr> <tr> <td><img src="./images/ranks/star.gif" alt="Power Poster" title="Power Poster" /></td> </tr> </table> <span class="postdetails"> <br /><b>Joined:</b> Wed Sep 08, 2004 3:32 pm<br /><b>Posts:</b> 524 </span> </td> <td valign="top"> <table width="100%" cellspacing="5"> <tr> <td> <div class="postbody">ostricized,<br /><br />you can use all values out of MenuManger, so the title-attribute should be obtained like this:<br /><br /><span style="color: Red"><strong>1. Create a user-defined tag called "get_parent_title" with following values</strong></span><br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent"><br />global $gCms;<br />global $smarty;<br /><br />$manager =& $gCms->GetHierarchyManager();<br /><br />$var = 'root_page_title';<br />if( isset($params['assign']) && $params['assign'] != '' )<br />{<br />  $var = $params['assign'];<br />}<br />$result = "NO RESULT";<br />$thisPage = $gCms->variables['content_id'];<br />$currentNode = &$manager->sureGetNodeById($thisPage);<br />while( isset($currentNode) && $currentNode->getLevel() >= 0 )<br />{<br />    $currentContent =& $currentNode->getContent();<br />    $result = $currentContent->Titleattribute();<br />    $currentNode =& $currentNode->getParentNode();<br />}<br />$smarty->assign($var,$result);<br /><br /></div><br /><br /><span style="color: Red"><strong>2. Put the following code into your website:</strong></span><br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent"><br />{get_title assign="root_page_title"} The root parents' title of this page is:{$root_page_title}<br /><br /></div><br /><br />This should do the trick.<br /><br />Regards,<br />Nils</div> <br clear="all" /><br /> <table width="100%" cellspacing="0"> <tr valign="middle"> <td class="gensmall" align="right"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr class="row1"> <td class="profile"><strong><a href="#wrapheader">Top</a></strong></td> <td><div class="gensmall" style="float: left;"> <a href="./memberlist.php?mode=viewprofile&u=20&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/icon_user_profile.gif" alt="Profile" title="Profile" /></a>  </div> <div class="gensmall" style="float: right;"> </div></td> </tr> <tr> <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> </tr> </table> <table class="tablebg" width="100%" cellspacing="1"> <tr class="row2"> <td align="center" valign="middle"> <a name="p82509"></a> <b class="postauthor" style="color: #AA0000">calguy1000</b> </td> <td width="100%" height="25"> <table width="100%" cellspacing="0"> <tr> <td class="gensmall" width="100%"><div style="float: left;"> <b>Post subject:</b> Re: Getting a page's root parent's alias</div><div style="float: right;"><a href="./viewtopic.php?p=82509&sid=de1d800585e2c62962960de36e270949#p82509"><img src="./styles/subsilver2/imageset/icon_post_target.gif" width="12" height="9" alt="Post" title="Post" /></a><b>Posted:</b> Tue Nov 06, 2007 10:54 pm </div></td> </tr> </table> </td> </tr> <tr class="row2"> <td valign="top" class="profile"> <table cellspacing="4" align="center" width="150"> <tr> <td><img src="./styles/subsilver2/imageset/en/icon_user_offline.gif" alt="Offline" title="Offline" /></td> </tr> <tr> <td class="postdetails">Dev Team Member</td> </tr> <tr> <td><img src="./images/ranks/stargmod.gif" alt="Dev Team Member" title="Dev Team Member" /></td> </tr> <tr> <td><img src="http://www.gravatar.com/avatar/1eeb158c79ff7f5f277ffed66e6ce257.jpg?s=80" width="80" height="80" alt="User avatar" /></td> </tr> </table> <span class="postdetails"> <br /><b>Joined:</b> Tue Oct 19, 2004 6:44 pm<br /><b>Posts:</b> 6583<br /><b>Location:</b> Fernie British Columbia, Canada </span> </td> <td valign="top"> <table width="100%" cellspacing="5"> <tr> <td> <div class="postbody">Four new methods in the CustomContent module do this:<br /><br />$ccuser->get_parent_alias($alias = '')  <-- get the alias of the parent of the specified page (use current page if no page is specified)<br />$ccuser->get_root_alias($alias = '') <-- get the alias of the root of the specified page (use current page if no page is specified)<br />$ccuser->get_page_title($alias = '') <-- get the title of the specified page (use current page if no page is specified)<br />$ccuser->has_children($alias = '')  <-- output a boolean indicating if the specified page has children (use current page if no page is specified)<br /><br />Just thought I'd let you know.</div> <div class="postbody"><br />_________________<br />Follow me on <a href="http://twitter.com/calguy1000" class="postlink">twitter</a><br />--<br />if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.<br />----------------<br />Don't make me angry..... you won't like me when I'm angry....</div> <br clear="all" /><br /> <table width="100%" cellspacing="0"> <tr valign="middle"> <td class="gensmall" align="right"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr class="row2"> <td class="profile"><strong><a href="#wrapheader">Top</a></strong></td> <td><div class="gensmall" style="float: left;"> <a href="./memberlist.php?mode=viewprofile&u=47&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/icon_user_profile.gif" alt="Profile" title="Profile" /></a>  </div> <div class="gensmall" style="float: right;"> </div></td> </tr> <tr> <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> </tr> </table> <table class="tablebg" width="100%" cellspacing="1"> <tr class="row1"> <td align="center" valign="middle"> <a name="p102348"></a> <b class="postauthor">joecannes</b> </td> <td width="100%" height="25"> <table width="100%" cellspacing="0"> <tr> <td class="gensmall" width="100%"><div style="float: left;"> <b>Post subject:</b> Re: Getting a page's root parent's alias</div><div style="float: right;"><a href="./viewtopic.php?p=102348&sid=de1d800585e2c62962960de36e270949#p102348"><img src="./styles/subsilver2/imageset/icon_post_target.gif" width="12" height="9" alt="Post" title="Post" /></a><b>Posted:</b> Thu Apr 10, 2008 2:45 pm </div></td> </tr> </table> </td> </tr> <tr class="row1"> <td valign="top" class="profile"> <table cellspacing="4" align="center" width="150"> <tr> <td><img src="./styles/subsilver2/imageset/en/icon_user_offline.gif" alt="Offline" title="Offline" /></td> </tr> <tr> <td class="postdetails">Forum Members</td> </tr> <tr> <td><img src="./images/ranks/star.gif" alt="Forum Members" title="Forum Members" /></td> </tr> </table> <span class="postdetails"> <br /><b>Joined:</b> Mon Nov 26, 2007 5:00 pm<br /><b>Posts:</b> 92<br /><b>Location:</b> Montreal, Quebec </span> </td> <td valign="top"> <table width="100%" cellspacing="5"> <tr> <td> <div class="postbody">I've inserted the code for getting the parent title, still not working...I am using CMSMS 1.2.3, and I do have the title defined.<br /><br />All I get is:<br /><br />The root parents' title of this page is:<br /><br />and then it is blank</div> <br clear="all" /><br /> <table width="100%" cellspacing="0"> <tr valign="middle"> <td class="gensmall" align="right"> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr class="row1"> <td class="profile"><strong><a href="#wrapheader">Top</a></strong></td> <td><div class="gensmall" style="float: left;"> <a href="./memberlist.php?mode=viewprofile&u=9509&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/icon_user_profile.gif" alt="Profile" title="Profile" /></a>  </div> <div class="gensmall" style="float: right;"> </div></td> </tr> <tr> <td class="spacer" colspan="2" height="1"><img src="images/spacer.gif" alt="" width="1" height="1" /></td> </tr> </table> <table width="100%" cellspacing="1" class="tablebg"> <tr align="center"> <td class="cat"><form name="viewtopic" method="post" action="./viewtopic.php?f=4&t=6914&sid=de1d800585e2c62962960de36e270949"><span class="gensmall">Display posts from previous:</span> <select name="st" id="st"><option value="0" selected="selected">All posts</option><option value="1">1 day</option><option value="7">7 days</option><option value="14">2 weeks</option><option value="30">1 month</option><option value="90">3 months</option><option value="180">6 months</option><option value="365">1 year</option></select> <span class="gensmall">Sort by</span> <select name="sk" id="sk"><option value="a">Author</option><option value="t" selected="selected">Post time</option><option value="s">Subject</option></select> <select name="sd" id="sd"><option value="a" selected="selected">Ascending</option><option value="d">Descending</option></select> <input class="btnlite" type="submit" value="Go" name="sort" /></form></td> </tr> </table> <table width="100%" cellspacing="1"> <tr> <td align="left" valign="middle" nowrap="nowrap"> <a href="./posting.php?mode=post&f=4&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/button_topic_new.gif" alt="Post new topic" title="Post new topic" /></a> <a href="./posting.php?mode=reply&f=4&t=6914&sid=de1d800585e2c62962960de36e270949"><img src="./styles/subsilver2/imageset/en/button_topic_reply.gif" alt="Reply to topic" title="Reply to topic" /></a> </td> <td class="nav" valign="middle" nowrap="nowrap"> Page <strong>1</strong> of <strong>1</strong><br /></td> <td class="gensmall" nowrap="nowrap"> [ 11 posts ] </td> <td class="gensmall" width="100%" align="right" nowrap="nowrap"></td> </tr> </table> </div> <div id="pagefooter"></div> <br clear="all" /> <table class="tablebg" width="100%" cellspacing="1" cellpadding="0" style="margin-top: 5px;"> <tr> <td class="row1"> <p class="breadcrumbs"><a href="./index.php?sid=de1d800585e2c62962960de36e270949">Board index</a> » <a href="./viewforum.php?f=72&sid=de1d800585e2c62962960de36e270949">Community Boards</a> » <a href="./viewforum.php?f=4&sid=de1d800585e2c62962960de36e270949">Tips and Tricks</a></p> <p class="datetime">All times are UTC </p> </td> </tr> </table> <br clear="all" /> <table class="tablebg" width="100%" cellspacing="1"> <tr> <td class="cat"><h4>Who is online</h4></td> </tr> <tr> <td class="row1"><p class="gensmall">Users browsing this forum: No registered users</p></td> </tr> </table> <br clear="all" /> <table width="100%" cellspacing="1"> <tr> <td width="40%" valign="top" nowrap="nowrap" align="left"></td> <td align="right" valign="top" nowrap="nowrap"><span class="gensmall">You <strong>cannot</strong> post new topics in this forum<br />You <strong>cannot</strong> reply to topics in this forum<br />You <strong>cannot</strong> edit your posts in this forum<br />You <strong>cannot</strong> delete your posts in this forum<br />You <strong>cannot</strong> post attachments in this forum<br /></span></td> </tr> </table> <br clear="all" /> <table width="100%" cellspacing="0"> <tr> <td><form method="post" name="search" action="./search.php?sid=de1d800585e2c62962960de36e270949"><span class="gensmall">Search for:</span> <input class="post" type="text" name="keywords" size="20" /> <input class="btnlite" type="submit" value="Go" /></form></td> <td align="right"> <form method="post" name="jumpbox" action="./viewforum.php?sid=de1d800585e2c62962960de36e270949" onsubmit="if(document.jumpbox.f.value == -1){return false;}"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td nowrap="nowrap"><span class="gensmall">Jump to:</span> <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ document.forms['jumpbox'].submit() }"> <option value="-1">Select a forum</option> <option value="-1">------------------</option> <option value="70">Official Boards</option> <option value="40">   README FIRST!!!</option> <option value="1">   Announcements</option> <option value="2">   General Discussion</option> <option value="3">   Installation, Setup and Upgrade</option> <option value="8">   Product Support</option> <option value="6">   Developers Discussion</option> <option value="23">   Accessability and Usability</option> <option value="19">   Quality Assurance</option> <option value="81">   Documentation</option> <option value="14">   Documentation0ld</option> <option value="16">      Suggestions, Modifications & Corrections</option> <option value="15">   Translations</option> <option value="74">   CMSMS 1.10 Beta</option> <option value="75">      Closed Issues</option> <option value="79">   [locked] CMSMS 1.11 Beta</option> <option value="80">      Closed Issues</option> <option value="72">Community Boards</option> <option value="76">   Geek Moot 2012</option> <option value="5">   CMS Show Off</option> <option value="35">   Media and presentations about CMSMS</option> <option value="34">   Help Wanted (commercial)</option> <option value="4" selected="selected">   Tips and Tricks</option> <option value="20">   Layout and Design (CSS & HTML)</option> <option value="7">   Modules/Add-Ons</option> <option value="21">   Feature ideas</option> <option value="28">   The Lounge</option> <option value="41">   Locked: CMSMS MLE fork</option> <option value="48">      Modules/Addon patchs</option> <option value="66">   Locked: Geek Moot 2010</option> <option value="73">International Discussions</option> <option value="42">   Czech/Slovak - Česky/Slovensky</option> <option value="9">   Danish - Dansk</option> <option value="13">   Dutch - Nederlands</option> <option value="51">      Aankondigingen</option> <option value="52">      Tips en Trucs</option> <option value="53">      Vertalingen & Documentatie</option> <option value="54">      Hulp gezocht (commercieel)</option> <option value="55">      Showroom</option> <option value="78">   Finnish - Suomi</option> <option value="10">   French - Français</option> <option value="11">   German - Deutsch</option> <option value="43">      BITTE ZUERST LESEN !!!</option> <option value="63">      Ankündigungen</option> <option value="24">      Installation und Einstellungen</option> <option value="25">      Module und Tags</option> <option value="50">      Smarty-Tipps und -Tricks</option> <option value="32">      Layout und Design</option> <option value="61">      Suchmaschinenoptimierung (SEO)</option> <option value="67">      HowTo's</option> <option value="49">      Übersetzungen</option> <option value="26">      Show Off</option> <option value="47">      Hilfe gesucht (kommerziell)</option> <option value="31">      Stammtisch</option> <option value="45">   Hungarian - Magyar</option> <option value="29">   Italian - Italiano</option> <option value="36">      Moduli/Plugins</option> <option value="33">   Lithuanian - Lietuviškai</option> <option value="60">      Darbo / bendradarbiavimo pasiūlymai ir paieška</option> <option value="59">   Persian / Farsi</option> <option value="12">   Polish - Polski</option> <option value="46">   Portuguese - português</option> <option value="27">   Russian - русский</option> <option value="56">      Предложения и поиск РАБОТЫ</option> <option value="30">   Spanish - Español</option> <option value="22">   Swedish - Svenska</option> </select> <input class="btnlite" type="submit" value="Go" /></td> </tr> </table> </form> </td> </tr> </table> </div> </div> <!-- We request you retain the full copyright notice below including the link to www.phpbb.com. This not only gives respect to the large amount of time given freely by the developers but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain the full copyright we ask you at least leave in place the "Powered by phpBB" line, with "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our forums may be affected. The phpBB Group : 2006 //--> </div> <div id="contentbtm"> <div id="adbox"> <a rel="nofollow" href="http://www.cmsmadesimple.org/index.php?mact=Banners,cntnt01,link,0&cntnt01banner_id=2&cntnt01category_id=1&cntnt01returnid=15" title="A2Hosting"><img src="http://www.cmsmadesimple.org/uploads/partner_banners/A2_Banner_728X90.png" width="728" height="90" alt="A2 Hosting"/></a> </div> </div> </div> <div id="foot"> <div id="footer"> <div id="wrapfooter"> <span class="copyright">Powered by <a href="http://www.phpbb.com/">phpBB</a> © 2000, 2002, 2005, 2007 phpBB Group<br /> </span> </div> </div> </div> </div> </body> </html>