Next/Previous Block
Permalink
Ok so...I am trying to work out how to extend the Next/Previous Block. Currently the block does not allow you to loop through all pages regardless of hierarchy, only through the current level.
My sitemap consists of around 7 parent pages, each with a few child pages of their own. I am building a knowledge base/help portal and want to be able to descend through the sitemap regardless of whether it is a parent or child page.
THERE SEEMS TO BE NOWHERE ON THE INTERNET ON HOW TO DO THIS? Now I am pretty confident it is a simple solution with just some simple logic...but I am very new to PHP. I am a Design/Front End Guy.
This is the code that will make it work apparently...(which would go in view.php yes??). I was given this and then explained to, how to adapt it to what I need it to do. The explanation has gone right over my head and fear to ask multiple times due to it being a new job :/
But I have absolutely no idea how to 'code' it. Understanding the MVC in a CMS and the millions of functions and objects all married to each other is still proving very difficult for me to understand.
Any help would be much appreciated!
My sitemap consists of around 7 parent pages, each with a few child pages of their own. I am building a knowledge base/help portal and want to be able to descend through the sitemap regardless of whether it is a parent or child page.
THERE SEEMS TO BE NOWHERE ON THE INTERNET ON HOW TO DO THIS? Now I am pretty confident it is a simple solution with just some simple logic...but I am very new to PHP. I am a Design/Front End Guy.
This is the code that will make it work apparently...(which would go in view.php yes??). I was given this and then explained to, how to adapt it to what I need it to do. The explanation has gone right over my head and fear to ask multiple times due to it being a new job :/
<?php $children = Page::getByID($controller->getCurrentPage())>getCollectionChildrenArray(1); foreach($children as $childCID) { $child = Page::getById($childCID); if($child->getAttribute('exclude_nav') != 1) { $class = (strpos(Page::getCurrentPage()->getCollectionPath(), $child->getCollectionPath()) === 0) ? 'current' : ''; } else { } } ?>
But I have absolutely no idea how to 'code' it. Understanding the MVC in a CMS and the millions of functions and objects all married to each other is still proving very difficult for me to understand.
Any help would be much appreciated!
Anyone wanna help out a bit more on this ?
cross ref:http://stackoverflow.com/questions/36767918/next-previous-block-con...
cross ref:http://stackoverflow.com/questions/36767918/next-previous-block-con...
Thanks for the bump :)
Example is the PageList block. The block will display a list of pages on your site. But you can take the basic code that runs that, and make your own code to do something specific for you, such as make a page template that loops through every certain page type and grabs data from those.
So yes you could try to override the built in block to tweak it for your needs, I recently did the same thing on the conversation block.
But sometimes its quicker to outline what you need, and then follow the functionality trail that gets you there.
If what you need is Prev/Next buttons that will loop through every page of the site, think about what you need in order to do that, then make it happen from there.
One thing that is really useful when getting into concrete5 development is the Exchange Developer Tools:http://www.concrete5.org/marketplace/addons/exchangecore-developer-...
Which has API links somewhat explaining what the code is doing behind the scenes. If you find any broken links, just changehttp://www.concrete5.org to documentation.concrete5.org
And remember, concrete5 is built with PHP, developing with concrete5 means being a PHP developer. A lot of times, the answer to a problem isn't "How to do this in Concrete5" but the answer is "How to do this in PHP" and then organize your code to fit into the Concrete5 methodology.
Also understand what files do what. If your use to front end coding, everything is relative, but in backend development, there is code running your code. view.php is the view for the object your working on. The controller.php controls what actually happens. If you are just changing the view of the plugin, then override view, but you may need to look inside the controller.php and override some of its functionality as well.