kaba86 Posted March 24, 2018 Share Posted March 24, 2018 (edited) Hello PW Community, really glad that discovered this CMS recently, it is very strange it took so long That idea of no front design limitations is just awesome! Need to say that I have a bit of knowledge of html and css, but almost no php, so I need your help. What I want to do is an article posting cms, with this structure: - Homepage - Projects - Articles -- Category 1 --- Articles of category 1 -- Category 2 --- Articles of category 2 - About - Contact Found this ProcessWire Profile https://github.com/tutsplus/how-to-create-an-ajax-driven-theme-for-processwire It covers almost all my needs, except the menu. When I add a childpage for this page http://artist.nicegrp.com/publications/world-world/ , World:World doesn't appear under Writings & Publications. I need a menu that works like a breadcrumb, that shows on the menu the category that you are viewing. So when I'm in articles page, on the menu it shows only articles and it's categories. When I get into a category, that category takes state active link but doesn't show on the menu links and titles for contained articles. How can I do that? Sorry for my long writing and English, it is not my native but I hope you understood what I need. Can you help me with that? Thank you Edited March 24, 2018 by kaba86 few edits Link to comment Share on other sites More sharing options...
monchu Posted March 24, 2018 Share Posted March 24, 2018 For quick study how to structure your pages and menus, try first Blog Profile You don't have to locate each article under category page. From Blog Profile you can learn how to use Page Reference field for category purpose. 1 Link to comment Share on other sites More sharing options...
kaba86 Posted March 24, 2018 Author Share Posted March 24, 2018 Thank you for your response monchu, I will give it a try. Still, if someone would like to help me out with code, would be really nice. Here is the code of the menu from the Artist profile. <?php $children = $pages->get('/')->children; foreach($children as $child){ $class = ""; if($page->id == $child->id){ $class = " current"; } if($child->id == $page->parent->id){ $class = " parent"; } // echo nav links echo '<a name="'.$child->title.'" class="ajax-link'.$class.'" href="'. $child->url .'">'. $child->title .'</a>'; } ?> Thank you 1 Link to comment Share on other sites More sharing options...
dragan Posted March 24, 2018 Share Posted March 24, 2018 I don't know how @benbyf structured his site, i.e. neither the tutorial or the GitHub ReadMe mention any of that. Why don't you just ask him? Personally, I would also tend to use page reference fields to create categories. Together with URL-segments (and maybe altering the JS a bit for the AJAX stuff and history.js functionality) this would be my choice of how to set up such a site. Looking at that code block above, it seems like you just need to check if $child has children (check for one more level deeper), and do some if/else stuff... 2 Link to comment Share on other sites More sharing options...
benbyf Posted March 24, 2018 Share Posted March 24, 2018 Hi @kaba86 as @dragan mentioned you can simply add another foreach loop to check another level down. I would defiantly check out some tutorials on using processwire to get yourself kickstarted in the right direction and theres lots of quality tutorials not to mention some of my own. https://processwire.com/docs/tutorials/ <?php $children = $pages->get('/')->children; foreach($children as $child){ $class = ""; if($page->id == $child->id){ $class = " current"; } if($child->id == $page->parent->id){ $class = " parent"; } // echo nav links echo '<a name="'.$child->title.'" class="ajax-link'.$class.'" href="'. $child->url .'">'. $child->title . '</a>'; // new code below $childChildren = $child->children; foreach($childChildren as $subChild){ $class = ""; if($page->id == $subChild->id){ $class = " current"; } if($child->id == $page->parent->id){ $class = " parent"; } echo "<div class='sub-item'>"; echo '<a name="'.$subChild->title.'" class="ajax-link'.$class.'" href="'. $subChild->url .'">'. $subChild->title . '</a>'; echo "</div>"; } } ?> The above is not optimised or elegent - just off the top of my head. I seem to remember one of the default themes has a funciton in it's _func.php file that gives you a nest page list given a page varible (and optional max depth) so you could use that too. Hope that helps (also please post you website when its done 3 1 Link to comment Share on other sites More sharing options...
kaba86 Posted March 25, 2018 Author Share Posted March 25, 2018 Thank you @benbyf for your help, appreciate it I will look for that function on default profiles, will replay when I get done what I want. Going to test now your addition to the code. 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