Automatically make new pages appear first in sub-menu [solved]
Automatically make new pages appear first in sub-menu [solved]
Hi everyone
I'm getting to grips with the Smarty language and CMSMS now which is great because it allows me to develop my skills but there's one thing that I'd like to be able to do but cannot figure out how.
When I create a new page using a particular parent (in this case Recent Work) I'd like each newly added page to appear at the TOP of the submenu and not added at the bottom, as ideally I'd like the newest first. Now, I know you can do this in the admin by using the re-order pages arrows but this is slightly impractical with the amount of pages I'm likely to have soon so if there's a Smarty code or something that can automatically place new pages at the top of the submenu, that would be great.
Has anyone got any ideas?
Thanks in advance,
Michael
I'm getting to grips with the Smarty language and CMSMS now which is great because it allows me to develop my skills but there's one thing that I'd like to be able to do but cannot figure out how.
When I create a new page using a particular parent (in this case Recent Work) I'd like each newly added page to appear at the TOP of the submenu and not added at the bottom, as ideally I'd like the newest first. Now, I know you can do this in the admin by using the re-order pages arrows but this is slightly impractical with the amount of pages I'm likely to have soon so if there's a Smarty code or something that can automatically place new pages at the top of the submenu, that would be great.
Has anyone got any ideas?
Thanks in advance,
Michael
Last edited by memerson on Fri Mar 27, 2009 12:45 pm, edited 1 time in total.
Re: Automatically make new pages appear first in sub-menu (without reordering!)
You can also use the Reorder Pages link at the bottom to drag and drop the pages where needed, I don't know of any programmable way to do it, others may...
Re: Automatically make new pages appear first in sub-menu (without reordering!)
one long way to do this is use the extra fields, and gain it via a UDT
then add this logic to your template
if extra field = 1
node
/if
if extra field != 1
node
/if
if you search thru the forum you'll find both...
Help this helps
Cheers
jeremyBass
then add this logic to your template
if extra field = 1
node
/if
if extra field != 1
node
/if
if you search thru the forum you'll find both...
Help this helps
Cheers
jeremyBass
Re: Automatically make new pages appear first in sub-menu (without reordering!)
Thanks for the help! However, I did find some code in the documentation in the end that will do this:
http://wiki.cmsmadesimple.org/index.php ... nu_Manager
under "inverse_menu".
Michael
http://wiki.cmsmadesimple.org/index.php ... nu_Manager
under "inverse_menu".
Michael
Re: Automatically make new pages appear first in sub-menu (without reordering!)
Actually, no, not really. The code given on the link was no use, since obviously that person didn't know Smarty language very well (he was using commands not existent in Smarty) but I think I'm going to resign to using the reorder section. Thanks for everyone's help!mark wrote: [solved] ?...
Re: Automatically make new pages appear first in sub-menu [solved]
Maybe there is some sort of smarty to sort ascending that you can put in your menu template...
Re: Automatically make new pages appear first in sub-menu [solved]
you could always create the menu in a UDT... then you can do what you ask... using
http://us.php.net/sort
or
http://us.php.net/manual/en/function.asort.php
and sort on creation date... that is a sure fire way, and really simple... plus I think there is a UDT close to this some where in here... I think I saw it...
@sort may work... but you'd need to pull the creation date in to...
{foreach from=$Wever|@sortby:$creationdate item=node}...
http://www.phpinsider.com/smarty-forum/ ... php?t=1079
by I don't think that is in the core...
Anyways... that will work...
Cheers
jeremyBass
http://us.php.net/sort
or
http://us.php.net/manual/en/function.asort.php
and sort on creation date... that is a sure fire way, and really simple... plus I think there is a UDT close to this some where in here... I think I saw it...
@sort may work... but you'd need to pull the creation date in to...
{foreach from=$Wever|@sortby:$creationdate item=node}...
http://www.phpinsider.com/smarty-forum/ ... php?t=1079
by I don't think that is in the core...
Anyways... that will work...
Cheers
jeremyBass
Last edited by JeremyBASS on Fri Mar 27, 2009 6:25 pm, edited 1 time in total.
Re: Automatically make new pages appear first in sub-menu [solved]
Hmm solved but no explanation as to how, and this may actually help someone else...
Re: Automatically make new pages appear first in sub-menu [s
Hi
This dont work at all. There is only long list of errors.
I need to sort nodes by datepost in my menu. Somebody can help with it? I using CMS 1.10.3.
Cheers.
This
Code: Select all
{foreach from=$nodelist|@sortby:$creationdate item=node}
I need to sort nodes by datepost in my menu. Somebody can help with it? I using CMS 1.10.3.
Cheers.
Re: Automatically make new pages appear first in sub-menu [s
Hi
I made a plugin modifier for sorting arrays of objects based on idea : http://www.i-do-this.com/blog/69/Sortin ... in-foreach
So, place this file under /plugins and name it modifier.sort_object_array or download it
Apply the modifier on your specific menu template who start on second level :
{foreach from=$nodelist|sort_object_array:'-created' item=node}
You can also use '-modified' for the latest modified pages.
'-' before value do the inverse sorting.
Beter help in french : http://www.cmsmadesimple.fr/forum/viewtopic.php?id=4439
I made a plugin modifier for sorting arrays of objects based on idea : http://www.i-do-this.com/blog/69/Sortin ... in-foreach
Code: Select all
<?php
/**
* Smarty plugin
*/
/**
* Smarty sort_object_array modifier plugin
*
* Type: modifier
* Name: sort_object_array
* Help : http://www.cmsmadesimple.fr/forum/viewtopic.php?id=4439
* @link
* @author Jean le Chauve
* @param array
* @param string
* @return array
* put '-' before the value for inverse
*/
function smarty_cms_modifier_sort_object_array($objArray, $sortby='')
{
if (!is_array($objArray)) {
die("not array, you cannot use the modificator sort_object_array with this variable");
}
$dir = '>';
if ($sortby[0] == '-')
{
$sortby = substr($sortby, 1);
$dir = '<';
}
$cmp = create_function('$a,$b', 'return strtolower($a->'.$sortby.')'.$dir.'strtolower($b->'.$sortby.');');
usort($objArray, $cmp);
return $objArray;
}
?>
{foreach from=$nodelist|sort_object_array:'-created' item=node}
You can also use '-modified' for the latest modified pages.
'-' before value do the inverse sorting.
Beter help in french : http://www.cmsmadesimple.fr/forum/viewtopic.php?id=4439
Re: Automatically make new pages appear first in sub-menu [s
Can I please for scripts for CMS 1.10?
Re: Automatically make new pages appear first in sub-menu [s
No, it is for cmsms 1.11
It is best to upgrade, if not today, it will do anyway one day or the other.
It is best to upgrade, if not today, it will do anyway one day or the other.