Printing menu-title based headings on lists

darkroast

Member
I was looking for a way to print the menu item title as the heading for the list, rather than the list name itself. I found this post, which helped:

http://fabrikar.com/forums/showthread.php?t=29512

After looking through the code for the Bootstrap template, I saw that there's a section which can generate this. It's located in lines 12-18 (of the current template, anyway), which are:

Code:
if ($this->params->get('show-title', 1)) {?>
   div class="page-header">
      <h1><?php echo this->table->label; ?></h1>
   </div>
<?php }
echo $this->table->intro;
?>

I changed it to:
Code:
if ($this->params->get('show-title', 1)) {?>
   <?php
      $app = JFactory::getApplication();
      $item = $app->getMenu('site')->getActive;
   ?>
   div class="page-header">
      <h1><?php echo this->table->label; ?></h1>
   </div>
<?php }
echo $this->table->intro;
?>

and that added the menu item text as the heading.

However, I also noted that this doesn't respect the setting of the show-title parameter; no matter whether I have the Show Title option on or off - or whether I have the Show Page Heading on or off for the menu item itself - it always shows. So it seems like that show-title parameter isn't getting used correctly.

This sounds like something which might be worth adding to the Bootstrap template. Here's how I (possibly) see this working:

  1. If both the list parameter and the menu parameter are OFF, don't show anything.
  2. If the menu item's Show Page Heading is on and the list's Show Title element is off, show the Menu Title
  3. If the menu item's Show Page Heading is off and the list's Show Title element is on, show the List name
  4. If both are on, the menu title controls (in case you use the same list in two different menu items, with different filters or something).

Does that sound like something doable? I think that would be a great addition. In fact, the same behavior could apply to forms as well.
 
hi

I think we already have separate parameters set up for this so:

PHP:
if ($params->get('show_page_title')) {
  echo '<h1>' . $params->get('page_title') . '</h1>';
}

take a look at components/com_fabrik/views/list/view.base.php's setTitle() method for more info on how we're doing that.
 
Well, the code in components/com_fabrik/views/list/tmpl/bootstrap/default.php doesn't seem to work. I always get the list name, regardless of what settings I use.

So I tried to replace lines 12-16 in components/com_fabrik/views/list/tmpl/bootstrap/default.php with the code you indicated, and I got an error message

Fatal error: Call to a member function get() on a non-object in /home/xxxx/xxxxx/components/com_fabrik/views/list/tmpl/bootstrap/default.php on line 12
 
Hi

This screen is where you can set global defaults for menu items that display articles. These default values will be used when you select "Use Global" for an option in an Articles menu item. For example, if you normally want to show the Create Date for an article in your Articles menu items, then set that option to "Show" here and it will be the default value. You do not need to set any of these options. Your Joomla site will work with the default settings.


Australia Immigration
 
sorry if its in the template it should be:

PHP:
if ($this->params->get('show_page_title')) {
  echo '<h1>' . $params->get('page_title') . '</h1>';
}
</span></span>
 
Rob, I tried that code, and...

1: with "Show Page Heading" on in the menu item, and "Show Title" off in the List Layout settings (in Fabrik), no title displayed.

2: With "Show Page Heading" off in the menu item and "Show Title" on in the list item on, no title.

3: With both on, no title.

Of course, I didn't try it with both off... that would just be silly :D
 
ok seems somewhere along the line things had got confused, or had changed related to the menu item parameters. So with the latest github update.....

For your menu item 'Advanced Options -> Page display options'
'Page Heading' will be shown IF 'Show Page Heading' = 'yes'

The list's 'title' will be shown IF 'layout -> show title' = yes

The two titles and their logic are included in all the list templates now, so no need to alter them
 
Hmmm... something's still not working. If I have the 'layout -> show title' = yes and the menu item 'Advanced Options -> Page display options' = yes, I get the list name, not the menu title.

If I have the 'layout -> show title' = no and the menu item 'Advanced Options -> Page display options' = yes, I get no heading at all.

I made a couple of changes to the code (to make it easier for me to follow the logic), and I'm not getting any errors - but the menu item title just doesn't show up.
 
If I have the 'layout -> show title' = yes and the menu item 'Advanced Options -> Page display options' = yes, I get the list name, not the menu title.
In this case I see BOTH the menu title AND the list title being shown. Are you using a custom list template? If so it would need to be updated with the latest layout changes. Also note that there are two title(ish) options in the menu item settings, one for the "browser page title" (which i think would be better labelled as "browser window title") and one for the "page heading" - you need to supply something in the "page heading" field for the menu item's 'Show Page Heading' to take effect.

So I've tested:

With a list title of 'List title'
and a menu item 'page heading' of 'Page heading':

====================================

list option - show title: YES
menu item - show page heading : YES:

output :
Code:
Page Heading
List title

====================================

list option - show title: NO
menu item - show page heading : YES:

output :
Code:
Page Heading

====================================

list option - show title: NO
menu item - show page heading : NO:

output :
Code:
(no headings shown)

====================================

list option - show title: YES
menu item - show page heading : NO:

output :
Code:
List title
 
Well, I just updated from Github (to release 202), and now the pages on which I want to use the menu item as the title don't work at all - all I get is a blank page.
 
I just found the error message that's being generated when I go to the pages in question:

Parse error: syntax error, unexpected T_SL in <snipped>/plugins/fabrik_element/textarea/textarea.php on line 156
 
Back
Top