pwusr Posted January 23, 2013 Share Posted January 23, 2013 I need to keep about 4-5 columns of links in my footer area / or in another div just above the footer. Each column will have a header and 4-5 links below it. All these are links to pages but in random order. Kindly let me know how I should go about it. Thanks a lot. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 23, 2013 Share Posted January 23, 2013 You could use a repeater field with inside: title input type Page (Multiple pages (PageArray) - Input field type AsmSelect) Then the amount of repeater items would be the amount of columns. ( for columns width, calculate the percentage, easiest to use inline style for it. ) So the title would become the header, each repeater field could output the url for pages you selected. Link to comment Share on other sites More sharing options...
pwusr Posted January 24, 2013 Author Share Posted January 24, 2013 Thanks a lot for your quick reply, @Martijn. I have created the repeater field as you suggested. I have a doubt regarding Selectable Pages field. If I select Home I can't see the children of the pages coming under Home page. (For ex: Children of About Us - The team, Gallery etc - are not visible. ) Then the amount of repeater items would be the amount of columns. So, does this mean I have to create 5 different repeater fields (each with title and set of links) if I have 5 columns of links? This has to be available on all pages, so do I create a template for this (set of links) Thanks in advance. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 24, 2013 Share Posted January 24, 2013 (edited) If you want this to set on all pages individually you could do this if you have a small amount of pages. But this approach is bad for scaleability. ( I don't think you should do this for 10 pages + ) You could however, set a default approach. On possible way to archief: - add your repeater field to the home template. - then add the field to your let say "basic template" $homepage = $pages->get('/'); $repeater = count($page->repeater) ? $page->repeater : $homepage->repeater; Then foreach your $repeater, beware that you have to foreach your pages array inside the repeater items to. So, if there are no repeater rows in the basic-page, the footer links set in the homepage is used. - repeater field - repeater-item // represets a column - title - fieldtype page ( array ) * page selected * page selected * page selected * an other page selected ) - repeater-item // represets an other column - title - fieldtype page ( array ) * page selected * page selected * page selected * an other page selected ) - repeater-item - title - fieldtype page ( array ) * page selected * page selected * page selected * an other page selected ) etc.... * code blocks works funky in editor (chrome / mac / Version 24.0.1312.56) Edited January 24, 2013 by Martijn Geerts Link to comment Share on other sites More sharing options...
pwusr Posted January 24, 2013 Author Share Posted January 24, 2013 Thanks @Martjin for your detailed reply. But being a newbie I couldn't understand some parts clearly. I don't think you should do this for 10 pages + I do have more than 10 pages - around 20 I have some basic doubts also: a)What should I select in the Selectable Pages (in the fields section) (If I select Home I can't see the children of the pages coming under Home page.) b) Do I have to create say, 5 different repeater fields if I have 5 columns of links? Thanks again. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 24, 2013 Share Posted January 24, 2013 I Think you should use a default so you don't have to set the urls on every page you create. a. The Selectable Pages you should select the pages where you want to have the link to. b. you need one repeater, in wich you can create for example 5 repeter-items. ( Every repeater-item then contains a title for your header and an array of pages for your list of links ) (So basicly every "row" is a column) ( You have to foreach the pages array inside the repeater to, and output the individual page ) Link to comment Share on other sites More sharing options...
pwusr Posted January 24, 2013 Author Share Posted January 24, 2013 Thank you. I Think you should use a default so you don't have to set the urls on every page you create. So maybe I should have for ex: a pagelinks.inc (like foot.inc) and include it in every file. you need one repeater, in wich you can create for example 5 repeter-items. How to create repeater-items within a repeater field. I tried but couldnt. As each repeater-item contains title and (links to) few pages they should be type repeater, if I am not mistaken. Please correct me if I am wrong. Thanks. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 24, 2013 Share Posted January 24, 2013 See the video ryan made about repeaters: http://processwire.com/videos/repeater-field-type/ inside the repeater: title input type Page (Multiple pages (PageArray) - Input field type AsmSelect) Link to comment Share on other sites More sharing options...
pwusr Posted January 24, 2013 Author Share Posted January 24, 2013 Thanks a lot.. I got that & I had also watched the excellent video by Ryan. Created Repeater field with Title & Page type fields. But I am slightly confused by this: you need one repeater, in wich you can create for example 5 repeter-items. ( Every repeater-item then contains a title for your header and an array of pages for your list of links ) According to the above: There is one Repeater field Each Repeater has for ex: 5 Repeater Items Each Repeater Items has a Title + Page (Array) Thank you for your patience. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 24, 2013 Share Posted January 24, 2013 yep, the structure I've drawn in the 4th post. $repeater = $page->repeater; // assumed that your repeater called: repeater $count = (int) count($repeater); // amount of columns $percentage = round((100 / $count), 5); // round the percentage if($count) { foreach($repeater as $item) { echo "<div style='float: left; width: {$percentage}%;'>\n"; echo "\t<h4>{$item->title}</h4>\n"; if(count($item->pages)) { echo "\t<ul>\n"; // if the fieldtype page is called pages foreach($item->pages as $p) { echo "\t\t<li><a href='{$p->url}'>{$p->title}</a></li>\n"; } echo "\t</ul>\n"; } echo "</div>\n"; } } Link to comment Share on other sites More sharing options...
pwusr Posted January 25, 2013 Author Share Posted January 25, 2013 Really appreciate your help, Martijn. I'll create for ex: a pagelinks.inc and put the above code in, then include it in whichever pages I want the links to appear in. Hope I am right. Thanks a lot. Link to comment Share on other sites More sharing options...
pwusr Posted January 30, 2013 Author Share Posted January 30, 2013 For the 'Selectable Pages' list to show the second level pages also (child pages of the top level pages) do we need any custom php code? Thank you. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 30, 2013 Share Posted January 30, 2013 Sorry I don't understand what you want to accomplice. Link to comment Share on other sites More sharing options...
pwusr Posted January 31, 2013 Author Share Posted January 31, 2013 Sorry for not making myself clear. In my repeater field I have a page (array) field . My website has the following structure -Home -About Us --Sub menu 1 --Sub menu 2 -Main Menu 3 -Main Menu 4 --Sub Menu 1 etc. On the page when I enter data for the repeater, the page field list shows only Top level pages ie., Home, About Us, Main Menu 3, Main Menu 4 etc. I cannot see (or select) the subpages. Home is selected as parent of selectable pages. How can I make the sub pages also available (in the list) to select them. Hope I have made myself clear. Thanks a lot. Link to comment Share on other sites More sharing options...
pwusr Posted February 1, 2013 Author Share Posted February 1, 2013 Kindly take a look at the image. About Us page (in the list) has 2 subpages but those are not shown in the list. Please tell me whether I should add any custom code in Selectable Pages section for this? Thank you. Link to comment Share on other sites More sharing options...
apeisa Posted February 1, 2013 Share Posted February 1, 2013 Change the inputfield from Select to PageListSelect. That shows pagetree and allows you to go deeper in structure. Link to comment Share on other sites More sharing options...
pwusr Posted February 1, 2013 Author Share Posted February 1, 2013 Thanks a lot, Apeisa. Sorry for missing the obvious.. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted February 1, 2013 Share Posted February 1, 2013 Thanks Antii & no need for tears pwuser. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now