The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
|
List of child pages in a template - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11) +--- Thread: List of child pages in a template (/showthread.php?tid=4114) |
List of child pages in a template - andy.storey - 2013-01-09 Hi All I would like to be able to create a custom template (done) that outputs all the usual GetSimple items but at the bottom of the page outputs a list of child pages (sometimes all, sometimes just the top 5). Would like to output the page title, description and of course an URL. Link to the website: http://cycling-jersey-collection.com/ Would anybody be kind enough to show be some sample php code for this? Don't need any help on the html. Many thanks andy RE: List of child pages in a template - Connie - 2013-01-09 Hi Andy, we did it like this in the sidebar of get-simple.de: If there are sub-pages, then they will be listed. It is done with the i18N-plugin which allows to create a menue with a defined starting depht: PHP Code: <?php test it, I am sure you can use it! RE: List of child pages in a template - andy.storey - 2013-01-09 (2013-01-09, 01:04:47)Connie Wrote: Hi Andy, Danke Connie. Unforetunately I do not want to install any i18n modules. I know they are very good, but I am tryng to keep GetSimple as simple as possible! Andy RE: List of child pages in a template - n00dles101 - 2013-01-09 PHP Code: $submenu=getChildren('index'); // change to $id for current page This should give you an array of children ($menuArray) Output as required... RE: List of child pages in a template - Carlos - 2013-01-09 You could also try the Hierarchical Menus plugin RE: List of child pages in a template - Connie - 2013-01-10 (2013-01-09, 17:20:13)Carlos Wrote: You could also try the Hierarchical Menus plugin Hi Carlos, as he does not want to use any plugin, this plugin or the other one, doesn't matter ;=) RE: List of child pages in a template - Carlos - 2013-01-10 He said he doesn't "want to install any i18n modules". I was going to suggest the Child Pages plugin, but I remembered about this one (which I think does support custom permalink structures). RE: List of child pages in a template - Connie - 2013-01-10 well, so this seems to be a personal decision not a general one, the reasons for that are unclear to me ;=) but he got other suggestions PLUS direct code, so I think everything is possible and will work. Cheers, Connie RE: List of child pages in a template - D.O. - 2013-01-10 Hi, I am interested in child pages too and asked help to n00dles101 but sadly his tip didn't work... so I tried something like that and - tho I am not a programmer - it worked fine! <?php echo "<ol>"; $submenu=getChildren($id); $menuArray=array(); foreach ($submenu as $menuitem) { echo "<li><a href='"; echo "?id="; echo getPageField($menuitem,url); echo "'>"; echo getPageField($menuitem,'title'); echo "</a></li>"; } echo "</ol>"; ?> I hope it will be useful. Thanks again N00d. RE: List of child pages in a template - andy.storey - 2013-01-10 All Many thanks for your help. Here's a code snippet of what I went for in the end. Andy PHP Code: if (return_page_slug() == 'blog') { RE: List of child pages in a template - Connie - 2013-01-11 Andy, thanks for sharing your snippet! I edited your post in order to mark that snippet as code... Cheers, Connie RE: List of child pages in a template - D.O. - 2013-01-12 Hi again GetSimplers, I was wondering if it is possible to add the date of publication of these codes. I tried with "pubDate" but it gives a date too long. I would like something simpler as 12/01/2013. Any help? <?php echo "<ol>"; $submenu=getChildren($id); $menuArray=array(); foreach ($submenu as $menuitem) { echo "<li><a href='?id="; echo getPageField($menuitem,url); echo "'>"; echo getPageField($menuitem,'puDate'); echo " - "; echo getPageField($menuitem,'title'); echo "</a></li>"; } echo "</ol>"; ?> RE: List of child pages in a template - Carlos - 2013-01-17 (2013-01-12, 18:32:48)D.O. Wrote: I was wondering if it is possible to add the date of publication of these codes. I tried with "pubDate" but it gives a date too long. I would like something simpler as 12/01/2013. That long number is a unix timestamp. You have to convert it to string (with php functions date or strftime) Try with this: PHP Code: echo date('d/m/Y', strtotime(returnPageField($menuitem,'pubDate'))); RE: List of child pages in a template - D.O. - 2013-01-17 Hi Carols and thanks for rerplying. Yes, a timestamp like this.. Mon, 07 Jan 2013 13:59:07 +0100... Sadly your solution doesn't work. It prints no date... <?php echo "<ul>"; $submenu=getChildren('turismo'); $menuArray=array(); foreach ($submenu as $menuitem) { echo "<li><a href='?id="; echo getPageField($menuitem,url); echo "'>"; echo "[".date('d/m/Y', returnPageField($menuitem,pubDate))."] "; echo getPageField($menuitem,title); echo "</a></li>"; } echo "</ul>"; ?> RE: List of child pages in a template - Carlos - 2013-01-17 Oops, a typo. I've just edited my post. So try: PHP Code: echo "[".date('d/m/Y', strtotime(returnPageField($menuitem,'pubDate')))."] "; btw it's 'pubDate', between quotes. RE: List of child pages in a template - D.O. - 2013-01-17 No worries hermano. Now it works perfectly. Thanks again! I am trying to use GS normal pages like a blog. Here's the final result... <?php echo "<ul>"; $submenu=getChildren($id); $menuArray=array(); foreach ($submenu as $menuitem) { echo "<li><a href='?id="; echo getPageField($menuitem,url); echo "'>"; echo "[".date('d/m/Y', strtotime(returnPageField($menuitem,pubDate)))."] "; echo getPageField($menuitem,title); echo "</a></li>"; } echo "</ul>"; ?> RE: List of child pages in a template - Carlos - 2013-01-17 You still missing quotes in pubDate, but I suppose it works anyway (tho if you enable debug mode you'll get some soft error). Time ago I made a quick and dirty plugin to do something like that, you may want to get some ideas from it: http://www.cyberiada.org/cnb/getsimple-plugin-recent-pages/ (needs some editing as it was made for GS 3.0, not 3.1) BTW another way to do the same, but using I18N Search: http://get-simple.info/forums/showthread.php?tid=1256&pid=31320#pid31320 RE: List of child pages in a template - D.O. - 2013-01-17 Thanks for these tips, mate! Now I am curious to test your plugin. It seems to be interesting. |