Date navigation block - hardcode to always show parent's pages?
Permalink
Hi all
I'm trying to show a date nav in a blog page type, but using page defaults it's not possible to specify that it should show pages underneath its parent. My site has several blogs, so each should show only the pages underneath its parent (i.e. from the same blog).
I presume it's like hardcoding the other blocks but I don't know the attributes of the date nav block.
Can any help?
I'm trying to show a date nav in a blog page type, but using page defaults it's not possible to specify that it should show pages underneath its parent. My site has several blogs, so each should show only the pages underneath its parent (i.e. from the same blog).
I presume it's like hardcoding the other blocks but I don't know the attributes of the date nav block.
Can any help?
I follow your steps but got this error:
As there a way to hardcode for date_nav in theme so this will be always show in front-end, just like auto-nav block.
And thanks for your great work...
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/html/imran/Concrete_5/concrete/concrete/blocks/date_nav/controller.php on line 65
As there a way to hardcode for date_nav in theme so this will be always show in front-end, just like auto-nav block.
<?php $bt = BlockType::getByHandle('autonav'); $bt->controller->displayPages = 'top'; $bt->controller->orderBy = 'display_asc'; $bt->controller->displaySubPages = 'all'; $bt->controller->displaySubPageLevels = 'custom'; $bt->controller->displaySubPageLevelsNum = '3'; $bt->render('templates/header_menu_dropdown'); ?>
And thanks for your great work...
Oops, I had a typo in my code. Step #3 should be this:
And yes there should be a way to hard-code the date nav into your templates, but you'll need to dig into the code to discover what the various settings are (look to the db.xml file in concrete/blocks/date_nav for a list of all options, although you will need figure out what those actually do, probably best to add the block to a page and see what settings correlate to which fields).
$this->cID = Page::getCurrentPage()->getCollectionID(); $cParentID = ($row['cThis']) ? $this->cID : $row['cParentID'];
And yes there should be a way to hard-code the date nav into your templates, but you'll need to dig into the code to discover what the various settings are (look to the db.xml file in concrete/blocks/date_nav for a list of all options, although you will need figure out what those actually do, probably best to add the block to a page and see what settings correlate to which fields).
Hello,
I also have some problem on hardcoding date navigation block. Here is what I have done trying:
I've implement this on two pages. One for page listing (with cParent go to it self) and one for post page (with cParent go to post page's parent, which is page listing).
At the page listing, they appeared fine (none of the items is it self) so the years appears all collapsed. But at the post page, The date nav is showing all items ( in tree-like mode and cannot be manipulated eg: collapsed). Does anyone experience this? How you guys solve it?
I've inclode the screenshot as how the appearance of hardcoded datenav at both pages.
EDIT:
Ok. I get it now. We need to include the css and js manually when hardcoding like this. Post this for anyone who had same problem as me.
I also have some problem on hardcoding date navigation block. Here is what I have done trying:
$bt = BlockType::getByHandle('date_nav'); $bt->controller->num = 0; $bt->controller->cParentID = $c->getCollectionParentID(); $bt->controller->cThis = 0; // this is one in the page listing, and 0 in the post page $bt->controller->ctID = 5; // this is the page type id that I want to retrieve $bt->controller->flatDisplay = 0; $bt->controller->default_node = 'current_page'; $bt->controller->truncateTitles = 1; $bt->controller->truncateSummaries = 0; $bt->controller->displayFeaturedOnly = 0; $bt->controller->truncateChars = 128; $bt->controller->truncateTitleChars = 128; $bt->controller->showDescriptions = 0; $bt->render('view');
I've implement this on two pages. One for page listing (with cParent go to it self) and one for post page (with cParent go to post page's parent, which is page listing).
At the page listing, they appeared fine (none of the items is it self) so the years appears all collapsed. But at the post page, The date nav is showing all items ( in tree-like mode and cannot be manipulated eg: collapsed). Does anyone experience this? How you guys solve it?
I've inclode the screenshot as how the appearance of hardcoded datenav at both pages.
EDIT:
Ok. I get it now. We need to include the css and js manually when hardcoding like this. Post this for anyone who had same problem as me.
I *think* this will fix the problem:
1) Edit the file YOURSITE/concrete/blocks/date_nav/controller.php
2) Find this chunk of code (should start around line #59):
3) Replace that chunk of code with this code:
Please let me know if that works for you or not -- if it does I want to submit this as a patch to the core so it's fixed in the future.
-Jordan