Tag Archives: item

Concrete5: Display the page title of the top parent menu item on sub pages

Here is the block of code I use to display the page title of the top parent menu item on a sub (or child) page of that menu item.

Copy this code:

<?php
$title = $c->getCollectionName();
$parentPageId = $c->getCollectionParentID();
if ($parentPageId > 1) {
    $parentPage = Page::getById($parentPageId);
    $title = $parentPage->getCollectionName();
}
?>
<h1><?php echo $title; ?></h1>
And paste it into the template where you want the parent item page title to appear.
Using this code, the page title of the top-level menu item relative to the page the viewer is on will always be displayed. For example, if this were your site map:
Home
About
      History
      Mission
Contact
      Directions
      Contact Us
Using the code above, you could display the page title About when you are on the History page or the Mission page, and the page title Contact when you are on Directions or Contact Us.

WordPress Tricks: Disable the parent links in a navigation menu

Here is the line of code I use to disable the top, or parent, links in a navigation menu in a WordPress site.

Insert this line of code into your header.php file, right before the closing <head> tag:

<script type="text/javascript">jQuery(function($) {    $("li.page-item-7").children("a").attr('href', "javascript:void(0)");});</script>

Now, simply change the page-item-7 to the ID of the page that you wish to disable. If you want to disable more than one of the parent menu items, use this code:

<script type="text/javascript">
jQuery(function($) {
$("li.page-item-7,li.page-item-14,li.page-item-20,li.page-item-28").children("a").attr('href', "javascript:void(0)");
});
</script>

Let me know if you run into any issues or have any questions at all.