irislines web design
irislines web design

Posts Tagged ‘template overrides’

Extensions/Languages/Language Overrides

Just posting this here to remind myself that when Joomla components are giving you things you don’t want, you might be able to solve it with an override of the component’s language file.

Recently a colleague Mark Madison was struggling to kill the display of the word Category:  in as site that uses SobiPro.   A language override was a quick and efficient way to deal with this,  vs a full-blown template override.

Thanks to Andy Tarr for pointing this out.

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.

 

 

 

What’s New in Templates for Joomla! 1.6?

I’m getting ready for two conferences this spring and have worked up a new Templates card with all the php snippets plus sections on Template Overrides, Layout Overrides, Custom Menu Item Types, and Parameters.

I’m in proofreading mode on the  NEW Template Cheat Sheet for Joomla! 1.6.   This one will be yellow with a yellow iris in the corners.

If you’d like a sneak peak, or to be a proofreader of the new one — before I go to print — email me and I’ll send you a pdf.    I’ll have a limited edition of the new sheet for Joomla Day New England, which is April 2, 2011.     I’ll also have both 1.5 and 1.6 Cheat Sheets for my presentations at CMS Expo May 2-4 in Evanston, IL.

Making Beez Better – typo!

My purple Template Cheat Sheet 2 handed out at Joomla! events in New England and the CMS Expo 2010 has a typo in the section called “Making Beez Better”

The sheet reads:
$this>escape

but should have said this:
$this->escape

Alas, that missing hyphen would lead to a fatal error!

My apologies to all, and kudos to my student Dawn Russell who discovered and pointed out the error.

The really good news is that none of that code will be needed in Template Overrides for Joomla! 1.6.   An opportunity to append a page class suffix to a top level

is now included in the Joomla! 1.6 core.

 

 

I’m in proofreading mode on a NEW Template Cheat Sheet for Joomla! 1.6.   This one will be yellow with a yellow iris in the corners.

If you’d like a sneak peak, or to be a proofreader of the new one — before I go to print — email me and I’ll send you a pdf.    I’ll have a limited edition of the new sheet for Joomla Day New England, which is April 2, 2011.     I’ll also have both 1.5 and 1.6 Cheat Sheets for my presentations at CMS Expo May 2-4 in Evanston, IL.

Modifying Read More links

A question was posted in the Joomla! New England  forum about getting rid of the titles from the read more links generated by the Beez template overrides.  Here is how I responded:

 

The Beez template was designed for accessibility.

It is an accessibility No-No  to have multiple links on the same page with the same text that point to different urls — so…
the Beez template overrides  pull in the article title, creating unique links to the various articles. Continue Reading

Greenhouse Website

At the CMS Expo I shared a site I had developed for the University of Massachusetts:  New England Greenhouse Up-dates  http://negreenhouseupdate.info.  I’ve gotten several emails from Expo attendees asking about the extensions used, so here’s that info.

Note:  I had to edit this blog entry in order to save it —  all references to up-dates would normallly not have the hyphen, but my host has great security and will not allow certain database terms to be used in an article or blog.   I will need to ask them to make an exception for this site and will edit the blog post once that is done.

The site features a blog of “up-dates” about all the things that can go wrong in greenhouses – and best practices to avoid them.  Some articles are just text, while a photo library provides a visual database organized in categories.  When we began the conversion to Joomla! we considered various photo gallery extensions, but ended up using regular Jooma! articles and two separate category blog displays.

For the greenhouse site we were most interested in a single search mechanism that would return “up-dates”  (text articles)  with “photos” (images with captions – sometimes article length) — we also wanted the client to be able to use the same interface for maintaining or adding new content of either type.

The extensions used to make this work were:   imagesized   to create the thumbnails from the normal article images  and

custom properties  for the tagging and search functionality that allowed searching by keyword, type of article and/or topic.

There was a template override with variables so that up-date article “readmores” would say “read more”  but the image library blog readmore links would be just the title.

I wrote that up in this blog post.

 

 

 

 

 

html overrides missing after update

That sinking feeling when after a version update things are broken — and you may not have a good backup…..

I’d run a complete package backup before running simplescripts Joomla updater, but what I hadn’t done was look at the site before running the backup. I’d trained the client to make changes just the day before — but how could that be messing up the template?

On this site, I’d not only borrowed the beez html folder, I’d just taken over the whole beez folder and made it my own. I had given my custom template a new name, but there was no beez template showing in the template manager.

After running the 1.5.14 to 1.5.15 update, all my category blogs were destroyed — using table code to display the content — ughh!

Recoginizing that the problem was that my overrides weren’t loading I thought I’d try setting beez as the default — but although there was a beez folder, it was only a folder of changes since the update — no xml file. So… I copied an entire beez folder over from another site I’d just updated. I applied beez as the default template — overrides loaded just fine. Back to my custom template — and voila! the overrides loaded and the site wasn’t broken after all!

Scary though — and an hour and a half of worrying and puzzling before it was solved.

Uh… maybe…. see post from August 7… Sure enough, to get MY html overrides to load, I had to once again delete the beez folder.

Different “read more” text for different sections.

(Note added 3/21/2011 – This article describes how to have one component output different html for different sections of a website.  New in Joomla 1.6 is the ability to do this with named alternative  overrides that can be selected as a parameter.  I’ll be posting about that soon!)

For  the negreenhouseupdate.info site   I used the extension “Imagesized”  to have large images resized when they appear in a blog layout.   This allowed me to have photo gallery content items with large image, and lengthy “captions” appear as a page of thumbnails with read more links that display ONLY the articles title.

THEN,   we realized we wanted to have the update articles display only introductory text with read more links, but really needed the words “read more”  for it to make sense.

I was already using html overrides from beez template, and modified the php:   content/category/blog_item.php to include this:

(Note:   section id 3 is the photo gallery, where we don’t want the words “read more” )

item->params->get(’show_readmore’) && $this->item->readmore && ($this->item->sectionid == 3)) : ?>

item->readmore_link; ?>” class=”readonitem->params->get(‘pageclass_sfx’); ?>”>
item->readmore_register) :
echo JText::_(‘Register to read more…’);
elseif ($readmore = $this->item->params->get(‘readmore’)) :
echo $readmore;
else :
echo JText::sprintf($this->item->title);
endif; ?>

 

item->params->get(’show_readmore’) && $this->item->readmore && ($this->item->sectionid != 3)) : ?>

item->readmore_link; ?>” class=”readonitem->params->get(‘pageclass_sfx’); ?>”>
item->readmore_register) :
echo JText::_(‘Register to read more…’);
elseif ($readmore = $this->item->params->get(‘readmore’)) :
echo $readmore;
else :
echo JText::sprintf(‘Read more: ‘,$this->item->title);
endif; ?>

 

IrisLines LLC
101 Washington Street
Brattleboro, VT 05301

802 257 7391

info@irislines.com