irislines web design
irislines web design

Posts Tagged ‘alternative layouts’

Category — Categories — which menu item to choose?

I’m preparing a talk for JoomlaDay NYC on Alternative Layouts and Custom Menu Item Types.  There had been so many posts on the joomla.org forum about these new capabilites of Joomla 1.6 and 1.7,  and so many were complaining that the “feature” simply didn’t work, I was getting a bit worried about the presentation.   I had proved them working back in the spring for a presenation at Joomla Day New England, but had things changed in the subsequent versions?

Finally last week I had a chance to put them all through their paces and the good news is that Alternative Layouts and Custom Menu Item Types DO indeed work —  for all kinds of Joomla items:   articles, contacts, weblinks, and category displays like blogs and lists.

The ONE Joomla entity where my template overrides (which worked) could not be turned into Alternative Layouts OR  Custom Menu Item Types  was the com_content layout for Categories.

I was trying to demonstrate using the sample data and the Parks Photo Gallery which is a demonstration of using regular articles to create a photo album of sorts.   I didn’t like that the Categories layout said  “Article count”  for each sub-category and wanted to change that to “Image count”. 

In the sample data, the menu item for the Parks Photo Gallery was set as a Categories  list.   When that didn’t work, I changed it to a Category list menu type and then applied my changes there.   Since there was a menu item to the top level category I had to take the further step and create the custom menu item type and then use that for the menu.   All well and good.   A parameter allowed me to skip the verbage  “There are no articles for this category”  and proceed directly to listing the sub-categories with their Image counts.

It’s had me thinking about when you would ever need the Categories layout, since I was able to get the same results with the Category layout.   Any ideas anyone?   Please email me!

 

Puzzled by alternative layouts not working?

My puzzle was that my alternative layout for a category blog would not show up as a choice in the category manager.

I turned to the Joomla Forum  and found that others had posted about their alternative layouts not being implemented, even when they chose them for a particular category.

Here’s what I posted in reply:

Alternative layouts will NOT be implemented if a menu item pointing to that category exists.   (Even if you arrive at the category via list, or other non-menu link.)

I have created templates/my-template/hmtl/com_content/category/blogworm.php    as well as blogworm_item.php   and blogworm_item.xml.

I have added lines in the .sys.ini language file for the new menu item type.

When I choose the alternative menu item, then my layout overrides are applied to the blog display of the category.

But it is not possible for me to select this category override in the category manager options or category manager for a particular category —   it does not appear in the menu of alternative layouts.

Having the .xml file precludes the use of the alternative as a an option to be selected at the category or item level.

I cloned my   .php files with yet another name and the alternative layout was  then available at the category level — and it worked on a category that had no menu item pointing to it.

The presence of the .xml file turns your layout override into a custom menu item type.  If you want or need both, you’ll have to clone the .php file with a new name.

Alternative layout overrides in Joomla! 1.6

Two years ago I blogged about a solution to have different “read-more” links for different sections of a website.

With Joomla! 1.6 it would be possible to have two variations of the php file that generates the blog,  one that would include the words “read-more” and one that wouldn’t.   Since this affects the display in the blog “page”, not the individual articles, this layout alternative would actually need to be an alternative menu item type.

Here’s how you would do it:

1.  Locate the php files that create the blog layout and blog layout menu item type:

     components/com_content/views/category/tmpl/blog.php
     components/com_content/views/category/tmpl/blog_items.php
     components/com_content/views/category/tmpl/blog.xml

2.  Make a copy of those three files and place them in your template’s html folder and rename them!  I’ve used blogworm.php…etc.  for blog without read more

     templates/your-template/html/com_content/category/blogworm.php
     templates/your-template/html/com_content/category/blogworm_items.php
     templates/your-template/html/com_content/category/blogworm.xml

3.  The change we’re talking about only requires a change in the blogworm_items.php file.

     at  line 155  (or nearby)  find:
     echo JText::_(‘COM_CONTENT_READ_MORE’);      and delete that.

4.  Open blogworm.xml and make changes to line 3:  you add a reference to your template at the beginning and change BLOG to BLOGWORM at the end of each of these strings:

 

      So what’s all that shouting about?   Those are strings that will be added to a language file, where you will provide a translation.

5.  Use TextEdit or NotePad to open your templates lanugage file — the .sys.ini one — or grab a copy from beez_20 as a starting point.  This file provides extra info about your template positions that shows up in the template manager.  It also provides info to display in the menu item manager.

     templates/beez_20/language/en-GB/en-GB.tpl_beez_20.sys.ini

     ADD to this file: 

TPL_BEEZ_20_COM_CONTENT_CATEGORY_VIEW_BLOGWORM_TITLE=”Beez 20  Blog without the words Read More”

TPL_BEEZ_20_COM_CONTENT_CATEGORY_VIEW_BLOGWORM_OPTION=”Beez 20 Blog without the words Read More”

TPL_BEEZ_20_COM_CONTENT_CATEGORY_VIEW_BLOGWORM_DESC=”Provides read more links without the words Read More – for use in photo gallery”

6.  Create a menu item to display this category as a blog with out the words “read more” in the read more links — choose your new menu item type from the menu item types list.

 

 

 

IrisLines LLC
101 Washington Street
Brattleboro, VT 05301

802 257 7391

info@irislines.com