Part 4 - Creating a Book Catalog in Joomla 1.5.x with FlexiContent CCK

on Saturday, 23 April 2011. Posted in PHP, Programming

Customizing a Template

Introduction

This part of the tutorial is a continuation of the customization of a template for displaying the product(s) created in the previous part of this tutorial. In part III we added the Product fields for the clone of the default FlexiContent template now we're going to customize it to fit the aesthetics of our site. This part of the tutorial requires you to modify PHP source code, XML and CSS files, so if you're familiar with these types of modifications let's dig in...

Getting to Know the Catalog Template

We'll explore the directory structure of FlexiContent templates so we can understand better the layout and customize it to taste.

  1. If you haven't done so already, login to the Joomla Administration control panel of your site and access the FlexiContent Component control panel from the components menu.
  2. Click the Templates tab
  3. Select the Category layout link/icon for the Catalog template we created in Part One/Part Three.
    • Note the User fields from the Product type in the upper right of the above screen. We dragged those fields to the Table zone in Part Three. Those zones are controlled or defined in the category.xml file of the FlexiContent template. Each template is free to define any zones they need. While the default table list format is fine in many instances it just doesn't fit a Product Catalog. What we'd like to see for our catalog is a two column summary of the item with a small image and links to the details of the product. We'll also learn how to modify the display of sub categories so we can use small graphics instead of the text links. Before we do that though we need to get to know the various files within a template and what aspects of the catalog display they control.
  4. This is what the directory structure of our template looks like (components/com_flexicontent/templates/catalog/)
  5. category.php - This file is the top level template used when displaying a FlexiContent category. It handles loading the other parts of the template for categories.
    • <?php
      /**
       * @version 1.5 stable $Id: category.php 171 2010-03-20 00:44:02Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      defined( '_JEXEC' ) or die( 'Restricted access' );
      ?>
      

      <?php //echo flexicontent_html::addbutton( $this->params ); ?> <?php echo flexicontent_html::printbutton( $this->print_link, $this->params ); ?> <?php echo flexicontent_html::mailbutton( 'category', $this->params, $this->category->slug ); ?>

      <?php if ($this->params->get( 'show_page_title', 1 ) && $this->params->get('page_title') != $this->category->title) : ?>

      <?php echo $this->params->get('page_title'); ?>

      <?php endif; ?> <?php if (($this->category->id > 0) && ((!empty($this->category->image) && $this->params->get('show_description_image', 1)) || ($this->params->get('show_description', 1)) || ($this->params->get('show_cat_title', 1)))) : echo $this->loadTemplate('category'); endif; ?> <?php //only show this part if subcategories are available if (count($this->categories) && $this->category->id > 0 && $this->params->get('show_subcategories')) : echo $this->loadTemplate('subcategories'); endif; ?> <?php echo $this->loadTemplate('items'); ?> <?php if ($this->params->get('show_pagination', 2) != 0) : ?> <?php if ($this->params->get('show_pagination_results', 1)) : ?>

      <?php echo $this->pageNav->getPagesCounter(); ?>

      <?php endif; endif; ?>
  6. category.png - This file is what's displayed in the administration area to give the admin a visual approximation of the layout for a category.
  7. category.xml - This file controls the various zones, the parameters for the template, the css files and the javascript files loaded by the template.
    • <?xml version="1.0" encoding="utf-8"?>
      
        Emmanuel Danan
        www.flexicontent.org
        emmanuel-at-vistamedia.fr
        GPLv2
        1.1
        25 november 2009
        This layout presents category items in a table. Each field put in the table position will be rendered as a column
        
        
        
          table
          
        
          css/category.css
        
        
          
              
              
  8. category_alpha.php - This file controls the alphabetic listing for filtering the display of items based on the title of the item.
    • <?php
      /**
       * @version 1.5 stable $Id: category_alpha.php 171 2010-03-20 00:44:02Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      defined( '_JEXEC' ) or die( 'Restricted access' );
      ?>
      
      
      <?php echo JText::_('FLEXI_ALL'); ?> <?php $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); foreach ($letters as $letter) : if (in_array($letter, $this->alpha)) : echo "".strtoupper($letter).""; else : echo "".strtoupper($letter).""; endif; endforeach; ?>
      <?php $numbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); foreach ($numbers as $number) : if (in_array($number, $this->alpha)) : echo "action."&letter=".$number."\" onclick=\"document.getElementById('alpha_index').value='".($number ? $number : 0)."';document.getElementById('adminForm').submit();\">".$number.""; else : echo "".$number.""; endif; endforeach; ?>
  9. category_category.php - This file controls the display of category specific parameters such as the category title, image and description.
    • <?php
      /**
       * @version 1.5 stable $Id: category_category.php 171 2010-03-20 00:44:02Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      
      defined( '_JEXEC' ) or die( 'Restricted access' );
      ?>
      
      
      <?php if ($this->params->get('show_cat_title', 1)) : ?>

      <?php echo $this->escape($this->category->title); ?>

      <?php endif; ?> <?php if (!empty($this->category->image) && $this->params->get('show_description_image', 1)) : ?>
      <?php echo JHTML::_('image.site', $this->category->image, 'images/stories/', NULL, NULL, $this->escape($this->category->title)); ?>
      <?php endif; ?> <?php if ($this->params->get('show_description', 1)) : ?>
      <?php echo $this->category->description; ?>
      <?php endif; ?>
  10. category_items.php - This file controls the display of item specific parameters within the category in a tablular format.
    • <?php
      /**
       * @version 1.5 stable $Id: category_items.php 283 2010-06-12 08:40:34Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      
      defined( '_JEXEC' ) or die( 'Restricted access' );
      // first define the template name
      $tmpl = $this->tmpl;
      ?>
      
      
      <?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search')) || ($this->params->get('show_alpha', 1))) : ?>
      
      <?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search'))) : ?>
      <?php if ($this->params->get('use_search')) : ?>
      <?php endif; ?> <?php if ($this->filters) : ?>
      <?php foreach ($this->filters as $filt) : echo ''; echo $filt->html; echo ''; endforeach; ?>
      <?php endif; ?>
      <?php endif; ?> <?php if ($this->params->get('show_alpha', 1)) : echo $this->loadTemplate('alpha'); endif; ?>
      <?php endif; ?> <?php if ($this->items) : // routine to determine all used columns for this table $layout = $this->params->get('clayout', 'default'); $fbypos = flexicontent_tmpl::getFieldsByPositions($layout, 'category'); $columns = array(); foreach ($this->items as $item) : if (isset($item->positions['table'])) : foreach ($fbypos['table']->fields as $f) : if (!in_array($f, $columns)) : $columns[$f] = @$item->fields[$f]->label; endif; endforeach; endif; endforeach; ?> <?php foreach ($columns as $name => $label) : ?> <?php endforeach; ?> <?php foreach ($this->items as $item) : ?> <?php foreach ($columns as $name => $label) : ?> <?php endforeach; ?> <?php endforeach; ?>
      <?php echo JText::_( 'FLEXI_ITEMS' ); ?><?php echo $label; ?>
      <?php if ($this->params->get('link_titles', 0)) : ?> <?php echo $this->escape($item->title); ?> <?php else : echo $this->escape($item->title); endif; ?> <?php echo isset($item->positions['table']->{$name}->display) ? $item->positions['table']->{$name}->display : ''; ?>
      <?php else : ?>
      <?php echo JText::_( 'FLEXI_NO_ITEMS_CAT' ); ?>
      <?php endif; ?>
  11. category_subcategories.php - This file controls the display of subcategory specific parameters such as the subcategory title and item count within each subcategory.
    • <?php
      /**
       * @version 1.5 stable $Id: category_subcategories.php 171 2010-03-20 00:44:02Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      
      defined( '_JEXEC' ) or die( 'Restricted access' );
      ?>
      
      <?php
      $n = count($this->categories);
      $i = 0;
      ?>
      
      <?php echo JText::_( 'FLEXI_SUBCATEGORIES' ) . ' : '; foreach ($this->categories as $sub) : $subsubcount = count($sub->subcats); ?> <?php echo $this->escape($sub->title); ?> <?php if ($this->params->get('show_itemcount', 1)) echo ' (' . ($sub->assigneditems != null ? $sub->assigneditems.'/'.$subsubcount : '0/'.$subsubcount) . ')'; $i++; if ($i != $n) : echo ', '; endif; endforeach; ?>
  12. index.html - This file is just a placeholder html file in case your web server displays file listings.
  13. item.php - This file is the top level template used when displaying a FlexiContent item. It handles loading the other parts of the template for items.
    • <?php
      /**
       * @version 1.5 stable $Id: item.php 250 2010-06-09 08:01:27Z emmanuel.danan $
       * @package Joomla
       * @subpackage FLEXIcontent
       * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
       * @license GNU/GPL v2
       *
       * FLEXIcontent is a derivative work of the excellent QuickFAQ component
       * @copyright (C) 2008 Christoph Lukes
       * see www.schlu.net for more information
       *
       * FLEXIcontent is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
       */
      
      defined( '_JEXEC' ) or die( 'Restricted access' );
      // first define the template name
      $tmpl = $this->tmpl;
      ?>
      
      

      <?php echo flexicontent_html::pdfbutton( $this->item, $this->params ); ?> <?php echo flexicontent_html::mailbutton( 'items', $this->params, null , $this->item->slug ); ?> <?php echo flexicontent_html::printbutton( $this->print_link, $this->params ); ?> <?php echo flexicontent_html::editbutton( $this->item, $this->params ); ?>

      <?php if ($this->params->get( 'show_page_title', 1 ) && $this->params->get('page_title') != $this->item->title) : ?>

      <?php echo $this->params->get('page_title'); ?>

      <?php endif; ?> <?php if ($this->params->get('show_title', 1)) : ?>

      <?php echo $this->escape($this->item->title); ?>

      <?php endif; ?> <?php if (isset($this->item->positions['subtitle1'])) : ?>
      <?php foreach ($this->item->positions['subtitle1'] as $field) : ?> <?php if ($field->label) : ?> <?php echo $field->label; ?> <?php endif; ?> <?php echo $field->display; ?> <?php endforeach; ?>
      <?php endif; ?> <?php if (isset($this->item->positions['subtitle2'])) : ?>
      <?php foreach ($this->item->positions['subtitle2'] as $field) : ?> <?php if ($field->label) : ?> <?php echo $field->label; ?> <?php endif; ?> <?php echo $field->display; ?> <?php endforeach; ?>
      <?php endif; ?> <?php if (isset($this->item->positions['subtitle3'])) : ?>
      <?php foreach ($this->item->positions['subtitle3'] as $field) : ?> <?php if ($field->label) : ?> <?php echo $field->label; ?> <?php endif; ?> <?php echo $field->display; ?> <?php endforeach; ?>
      <?php endif; ?> <?php if ((isset($this->item->positions['image'])) || (isset($this->item->positions['top']))) : ?>
      <?php if (isset($this->item->positions['image'])) : ?> <?php foreach ($this->item->positions['image'] as $field) : ?>
      <?php echo $field->display; ?>
      <?php endforeach; ?> <?php endif; ?> <?php if (isset($this->item->positions['top'])) : ?>
        <?php foreach ($this->item->positions['top'] as $field) : ?>
      • <?php if ($field->label) : ?>
        <?php echo $field->label; ?>
        <?php endif; ?>
        <?php echo $field->display; ?>
      • <?php endforeach; ?>
      <?php endif; ?>
      <?php endif; ?>
      <?php if (isset($this->item->positions['description'])) : ?>
      <?php foreach ($this->item->positions['description'] as $field) : ?> <?php if ($field->label) : ?>
      <?php echo $field->label; ?>
      <?php endif; ?>
      <?php echo $field->display; ?>
      <?php endforeach; ?>
      <?php endif; ?>
      <?php if (isset($this->item->positions['bottom'])) : ?>
        <?php foreach ($this->item->positions['bottom'] as $field) : ?>
      • <?php if ($field->label) : ?>
        <?php echo $field->label; ?>
        <?php endif; ?>
        <?php echo $field->display; ?>
      • <?php endforeach; ?>
      <?php endif; ?> <?php if ($this->params->get('comments')) : ?>
      <?php if ($this->params->get('comments') == 1) : if (file_exists(JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php')) : require_once(JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php'); echo JComments::showComments($this->item->id, 'com_flexicontent', $this->escape($this->item->title)); endif; endif; if ($this->params->get('comments') == 2) : if (file_exists(JPATH_SITE.DS.'plugins'.DS.'content'.DS.'jom_comment_bot.php')) : require_once(JPATH_SITE.DS.'plugins'.DS.'content'.DS.'jom_comment_bot.php'); echo jomcomment($this->item->id, 'com_flexicontent'); endif; endif; ?>
      <?php endif; ?>
  14. item.png - This file is what's displayed in the administration area to give the admin a visual approximation of the layout for an item.
  15. item.xml - This file controls the various zones, parameters for the item, the css files and the javascript files loaded by the template.
    • <?xml version="1.0" encoding="utf-8"?>
      
        Emmanuel Danan
        www.flexicontent.org
        emmanuel-at-vistamedia.fr
        GPLv2
        1.1
        25 november 2009
        Modular item layout suitable for faq, file manager, or directory
        
          
            
            
            
          
          
            
            
            
          
        
        
          subtitle1
          subtitle2
          subtitle3
          image
          top
          description
          bottom
          
        
          css/item.css
        
        
          
              
              
  16. css/category.css - This is the basic style sheet for a category. (this file is actually blank by default)
  17. css/item.css - This is the basic style sheet for an item.
    • /* Default Theme : item template CSS file */
      div.subtitle1 {
        display: block;
        margin: 0 0 0.5em;
        overflow: hidden;
      }
      div.lineinfo {
        display: block;
        margin: 0 0 0.5em;
        overflow: hidden;
      }
      div.subtitle1 {
      }
      div.subtitle2 {
      }
      div.subtitle3 {
      }
      div.subtitle1 .element {
      }
      div.subtitle2 .element {
        float: left;
        margin-right: 10px;
      }
      div.subtitle3 .element {
      }
      div.topblock {
        overflow: hidden;
        width: 100%;
        margin-bottom: 10px;
      }
      
      div.topblock .image {
        border: 1px solid silver;
        float: left;
        margin-right: 10px;
        line-height: 0px;
      }
      div.topblock .image a {
        outline: none;
      }
      div.topblock .image img {
        border: 1px solid white;
      }
      div.topblock .infoblock {
        overflow: hidden;
      }
      
      div.infoblock {
        border: 1px solid silver;
        margin: 0 0 10px;
        padding: 10px;
      }
      #flexicontent div.infoblock ul {
        margin: 0;
        padding: 0;
      }
      #flexicontent div.infoblock ul li {
        padding: 0;
        background: none;
        min-height: 10px;
        display: -moz-inline-stack;
        display: inline-block;
        vertical-align: top;
        margin: 2px;
        zoom: 1;
        *display: inline;
        _height: 10px;
      }
      div.label {
        float: left;
        border-bottom: 1px solid silver;
        color: #777;
        font-size: 90%;
      }
      div.value {
        float: left;
      }
      
      div.onecols ul li {
        width: 100%;
      }
      div.onecols div.label {
        width: 20%;
        margin-right: 2%;
      }
      div.onecols div.value {
        width: 76%;
      }
      
      div.twocols ul li {
        width: 48%;
      }
      div.twocols div.label {
        width: 34%;
        margin-right: 2%;
      }
      div.twocols div.value {
        width: 60%;
      }
              
              
  18. css/index.html - This file is just a placeholder html file in case your web server displays file listings.
  19. administrator/language/en-GB/en-GB.com_flexicontent.ini – This holds the language specific strings for the administration of the component.
  20. language/en-GB/en-GB.com_flexicontent.ini – This holds the language specific strings for the front-end of the component.

Now you have an idea of the basic files involved in the display of an item in FlexiContent. Now let's customize our own look. The first thing we'll need to modify is the category.xml file and define the new zones.

Create New Zones for the Catalog Template

Open the category.xml file in your favorite text/programming editor. As mentioned previously in Part III a different look is needed for our catalog. Specifically the table format just doesn't fit in with the rest of the website. Here's what we're looking to create in case you missed it in Part III:

  1. Change the section under fieldgroups to look like the following:
    •   
          topblock
          image
          detailblock
          bottomblock
                  
              
    • If you want to jump ahead here's all the modifications to the xml file.
      <?xml version="1.0" encoding="utf-8"?>
      
        John Wicks
        www.greatlittlebook.com
        johnw-at-greatlittlebook.com
        GPLv2
        0.99.0
        March 2010
        Catalog layout with featured products and multiple theme variations
        
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
              
          
          
          
          
          
          
              
          
          
          
              
          
          
          
          
          
          
          
              
          
          
          
          
        
        
          topblock
          image
          detailblock
          bottomblock
          
        
          css/category.css
        
        
          
              
              
    These groups or Zones will be used to drag and drop fields where we want them in the design of our catalog. The names can be anything you like but you should try to give them a name that describes their usage.
  2. If you save the xml file now and open the category template in the administration area you'll notice that our fields have reverted back to their default position on the lower left in the User fields group. Also if you look at the front-end of the site you'll only see the title of our item. This is the default look and since we've gotten rid of the table zone, no user fields are displayed.
  3. From the FlexiContent Category Template administration area do the following:
  4. Drag the Title field from the Core fields to the TopBlock Zone on the right.
  5. Drag the Image field from the Core fields to the Image Zone on the right.
  6. Drag the Price field from the User fields to the DetailBlock Zone on the right.
  7. Drag the Bundled With field from the User fields to the DetailBlock Zone on the right.
  8. Drag the Cart Link field from the User fields to the DetailBlock Zone on the right.
  9. Drag the Teaser Items field from the User fields to the BottomBlock Zone on the right.
    You might have noticed the new graphic on the left that displays the new Zones. This is controlled by the category.png file and you can create it with your favorite graphics editor. I used a 325x284 pixels image and placed the various zones as 50% greyed selections with Text layers over the top.
  10. Click the Apply button. Here's what it looks like on the front-end now.
    You might be saying, Looks the same as before, that's because our code is still using the old Table zone layout and hasn't accounted for the new zones, so the fields aren't displayed. Only the default title field is displayed.

Now you have the basic zones for the category layout as well as the fields we want to display in them. Now it's time to modify the code so we can display them.

Modify the Category Template Code

Then next file we'll be modifying is the category display file, category.php. We want to change some sections around and actually add a file called category_form.php which will contain the form code displayed at the top of the page. Here the complete directory structure and files:

<?php
/**
 * @version 1.5 beta 5 $Id: default.php 85 2009-10-10 13:48:04Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php //echo flexicontent_html::addbutton( $this->params ); ?> <?php echo flexicontent_html::printbutton( $this->print_link, $this->params ); ?> <?php echo flexicontent_html::mailbutton( 'category', $this->params, $this->category->slug ); ?>

<?php if ($this->params->get( 'show_page_title', 1 ) && $this->params->get('page_title') != $this->category->title) : ?>

<?php echo $this->params->get('page_title'); ?>

<?php endif; ?> <?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search')) || ($this->params->get('show_alpha', 1))) : echo $this->loadTemplate('form'); endif; ?> <?php if (($this->category->id > 0) && ((!empty($this->category->image) && $this->params->get('show_description_image', 1)) || ($this->params->get('show_description', 1)) || ($this->params->get('show_cat_title', 1)))) : echo $this->loadTemplate('category'); endif; ?> <?php //only show this part if subcategories are available if (count($this->categories) && $this->category->id > 0 && $this->params->get('show_subcategories')) : echo $this->loadTemplate('subcategories'); endif; ?> <?php echo $this->loadTemplate('items'); ?> <?php if ($this->params->get('show_pagination', 2) != 0) : ?> <?php if ($this->params->get('show_pagination_results', 1)) : ?>

<?php echo $this->pageNav->getPagesCounter(); ?>

<?php endif; endif; ?>

You be able to tell we've rearranged the order in which the other templates are loaded and added the loadTemplate('form'). This is mainly cause I prefer to see the search and alpha list near the top of the page rather than near the middle of it. Your needs/preferences may differ and that's one of the strengths of FlexiContent is you can decide what you want to change.

The next file in the list is the new form code template, category_form.php:

<?php
/**
 * @version 1.5 beta 5 $Id: default_items.php 85 2009-10-10 13:48:04Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
?>


<?php if ($this->params->get('show_alpha', 1)) : echo $this->loadTemplate('alpha'); endif; if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search'))) : ?>
<?php if ($this->params->get('use_search')) : ?>
<?php endif; ?> <?php if ($this->filters) : ?>
<?php foreach ($this->filters as $filt) : echo ''; echo $filt->html; echo ''; endforeach; ?>
<?php endif; ?>
<?php endif; ?>

The next file is the category_alpha.php file. Not much has changed in this file except I've consolidated the numerals into the catch-all * item. It has become clear that this code isn't very international and I'll leave that modification for another tutorial.

<?php
/**
 * @version 1.5 beta 5 $Id: blog_alpha.php 85 2009-10-10 13:48:04Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
  • Alphabetic Index

  • *
  • <?php $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); foreach ($letters as $letter) : if (in_array($letter, $this->alpha)) : echo "
  • ".strtoupper($letter)."
  • "; else : echo "
  • ".strtoupper($letter)."
  • "; endif; endforeach; ?>
  • 0-9

The next file is the category_category file.

<?php
/**
 * @version 1.5 beta 5 $Id: default_category.php 85 2009-10-10 13:48:04Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php if ($this->params->get('show_cat_title', 1)) : ?>

<?php echo $this->escape($this->category->title); ?>

<?php endif; ?> <?php if (!empty($this->category->image) && $this->params->get('show_description_image', 1)) : ?>
<?php echo JHTML::_('image.site', $this->category->image, 'images/stories/', NULL, NULL, $this->escape($this->category->title)); ?>
<?php endif; ?> <?php if ($this->params->get('show_description', 1) && !empty($this->category->description)) : ?>
<?php echo $this->category->description; ?>
<?php endif; ?>

Next we modify the category_subcategories.php file:

<?php
/**
 * @version 1.5 beta 5 $Id: default_subcategories.php 127 2009-10-14 15:28:59Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<?php
$n = count($this->categories);
$cols = $this->params->get('subcategory_columns',4);
$i = 0;
?>
<?php echo JText::_( 'FLEXI_SUBCATEGORIES' ) . ' : '; foreach ($this->categories as $sub) : $subsubcount = count($sub->subcats); ?> <?php echo $this->escape($sub->title); ?> <?php if ($this->params->get('show_itemcount', 1)) echo ' (' . ($sub->assigneditems != null ? $sub->assigneditems.'/'.$subsubcount : '0/'.$subsubcount) . ')'; $i++; if ($i != $n) : echo ', '; endif; endforeach; ?>

Lastly the category_items file:

<?php
/**
 * @version 1.5 beta 5 $Id: default_items.php 85 2009-10-10 13:48:04Z vistamedia $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
// first define the template name
$tmpl = $this->tmpl;
$itemCount = 1;
$colCount = $itemCount;
$itemsTotal = count($this->items);
$price= '';
$catColumns = $this->params->get('category_item_columns',2);
if ($this->items) :
  // routine to determine all used columns for this table
  $columns = array();
  foreach ($this->items as $item) :
    if (isset($item->positions['image'])) :
      foreach ($item->positions['image'] as $pos) :
        if (!in_array($pos->name, $columns)) :
          $columns[$pos->name] = $item->fields[$pos->name]->label;
        endif;
      endforeach;
    endif;
  endforeach;
?>
<?php foreach ($this->items as $item) : ?> <?php ($itemCount%$catColumns > 0? $col='col'.$colCount : $col='col'.$catColumns);?>
<?php foreach ($columns as $name => $label) : ?> <?php if ($name == 'title') : ?>
<?php if ($this->params->get('link_titles', 0)) : ?> <?php echo $this->escape($item->title); ?> <?php else : echo $this->escape($item->title); endif; ?>
<?php elseif ($name == 'image') : ?> <?php else : ?>
<?php echo isset($item->positions['image']->{$name}->display) ? $item->positions['image']->{$name}->display : ''; ?>
<?php endif; ?> <?php endforeach; ?>
<?php if($itemCount%$catColumns == 0 || $itemCount == $itemsTotal): ?>
<?php $colCount=0; endif; ?> <?php $itemCount++; $colCount++;?> <?php endforeach; ?>
<?php else : ?>
<?php echo JText::_( 'FLEXI_NO_ITEMS_CAT' ); ?>
<?php endif; ?>

Actually we have another couple files to modify the category.css file:

/*
 * alpha-index
 */
div.alpha-wrapper{ float: left; height:42px; width: 100%; margin: 0; clear: both; overflow: hidden; background: url('../images/alpha-index.png') top center no-repeat;}
ul.alpha-index {
  height: 30px;
  list-style-type: none;
  top: 0;
  margin: 0 auto;
  width: 98%;
}
.alpha-index li.alpha-first{
  position: absolute;
  height: 30px;
  width: 15px;
  left: 0;
  margin-left: -15px;
  padding-left: 0;
}
.alpha-index li.alpha-first+li{
  border-left: 1px solid #fff;
}
.alpha-index li.alpha-first h3{
  display: none;
}
.alpha-index li {
  display: inline-block;
  line-height: 30px;
  margin: 0;
  padding: 0px 3px 0px 3px;
  border-right: 1px solid #fff;
}
.alpha-index li a span{
  display: inline-block;
  line-height: 30px;
}
.alpha-index a:link, .alpha-index a:visited, .alpha-index li a#letter-all {
  color: #FFF;
  text-decoration: none;
}
li.alpha-letter:hover{
  background-color: #71899d;
}
.alpha-index a:hover {
  color: #FFF;
  text-decoration: none;
  background-color: #71899d;
}
.alpha-index a:active{
}
.alpha-index span {
  cursor: pointer;
}
.alpha-index li.alpha-last{
  position: absolute;
  height: 30px;
  width: 20px;
  top: 0;
  right: 0;
  margin-right: -20px;
}
.alpha-index li.alpha-last span{
  display: none;
}
.alpha-index li.disabled{
  color: #0e2b44;
}
.alpha-index li.disabled:hover{
  background-color: transparent;
}

/*
 * content
 */
div#flexicontent #fc_filter {
  border: none;
  margin: 0;
  padding: 0;
}
div#flexicontent .floattext
{ display:block; margin: 0;}

div.topblock {
  border-bottom: 1px solid silver;
}
div.topblock_nolabel {
  border-bottom: 1px solid silver;
}

div.bottomblock {
  border-top: 1px solid silver;
}
div.bottomblock_nolabel {
  border-top: 1px solid silver;
}

div.description {
  color: #333;
  text-align: left;
  display: block;
  padding-top: 5px;
}
div.header {
  font-family: Verdana, Geneva, sans-serif;
  font-size: 18px;
  line-height: 30px;
  font-weight: bold;
}
div.label {
  float: left;
  color: #777;
  font-weight: bold;
}
div.value {
  float: left;
}
#flexicontent div.bottomblock ul {
  margin: 0;
  padding: 0;
}
#flexicontent div.bottomblock ul li {
  padding: 0;
  background: none;
  min-height: 10px;
  display: -moz-inline-stack;
  display: inline-block;
  vertical-align: top;
  margin: 2px;
}
#flexicontent div.topblock ul {
  margin: 0;
  padding: 0;
}
#flexicontent div.topblock ul li {
  padding: 0;
  background: none;
  min-height: 10px;
  display: -moz-inline-stack;
  display: inline-block;
  vertical-align: top;
  margin: 2px;
}

div.onecols ul li {
  width: 100%;
}
div.onecols div.label {
  width: 20%;
  margin-right: 2%;
}
div.onecols div.value {
  width: 76%;
}

div.twocols ul li {
  width: 48%;
}
div.twocols div.label {
  width: 34%;
  margin-right: 2%;
}
div.twocols div.value {
  width: 48%;
}
div#flexicontent div.floattext div.catimg {
margin: 0;
float: left;
position: relative;
width:100%;
}
div#flexicontent div.floattext div.catimg img{ display:block; margin: 0 auto;}

div.category-items-list{
  position: relative;
}

div.category-item.cols1.col1
{width: 100%;}
div.category-item.cols2.col1,div.category-item.cols2.col2 {
  float: left;
  width: 48%;
  margin-right: 2%;
}

div.category-item.col1 {
  position: relative;
  min-height: 320px;
}
div.category-item.col2 {
  position: relative;
  min-height: 320px;
}
div.category-item-field-title {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 14px;
  font-weight: bold;
}
div.category-item-field-image {
  position: relative;
  top: 54px;
}
div.category-item-fieldinfo_wrapper {
  width: 100%;
}
div.category-item-field-pricelink_wrapper {
  width: 300px;
  position: relative;
  float: right;
  left: 140px;
  top: -130px;
}
div.category-item-field-price {
  font-weight: bold;
  color: red;
  margin-left: 100px;
}
div.category-item-field-price:before{
  content: "$ ";
}
div.category-item-field-price-free{display:none;}

div.category-item-field-author {
  position: relative;
  left: 0;
  top: 74px;
  font-weight: bold;
  font-style: italic;
  font-size: 12px;
}
div.category-item-field-cart_link {
  font-size: 11px;
}

div.category-item-field-bundled_with{
  position: absolute;
  left: 0;
  bottom: 10px;
  font-size: 8px;
  font-style: italic;
}
div.category-item-field-teaser_desc_wrapper {
  width: 60%;
  position: relative;
  left: 120px;
  top: -100px;
}
div.category-item-field-teaser_desc {
  font-size: 11px;
}
div.category-item-field-teaser_desc p, div.category-item-field-teaser_desc ul li{margin:0;}
div.category-item-field-teaser_desc ul li{line-height:11px;}
div.category-item-field-teaser_items {
  position: absolute;
  left: 180px;
  top: 70px;
  font-size: 9px;
  font-style: italic;
}
div.category-item-field-cart_link a[title="Add the Book to My Cart!"]{background-image: url(../images/cart_button_book.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the CD to My Cart!"]{background-image: url(../images/cart_button_cd.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the E-Book to My Cart!"]{background-image: url(../images/cart_button_ebook.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the Seminar to My Cart!"]{background-image: url(../images/cart_button_seminar.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the Bundle to My Cart!"]{background-image: url(../images/cart_button_bundle.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the MP3 to My Cart!"]{background-image: url(../images/cart_button_mp3.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the DVD to My Cart!"]{background-image: url(../images/cart_button_dvd.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the Kit to My Cart!"]{background-image: url(../images/cart_button_kit.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the System to My Cart!"]{background-image: url(../images/cart_button_system.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the Whitepaper to My Cart!"]{background-image: url(../images/cart_button_whitepaper.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}
div.category-item-field-cart_link a[title="Add the Course to My Cart!"]{background-image: url(../images/cart_button_course.png); display: block; height: 25px; text-indent: -9999px; width: 150px;}

div.category-item div.category-item-field-cart_link a {margin-bottom: -20px; line-height: 25px;}

and the administrator/language/en-GB/en-GB.com_flexicontent.ini file (add the following to the end):

#JWWicks Modifications
FLEXI_THEME_VARIATION_TYPE=Theme Type
FLEXI_THEME_VARIATION_TYPE_DESC=Changes the template theme for the Category
FLEXI_THEME_VARIATION_TYPE_DARK=Dark
FLEXI_THEME_VARIATION_TYPE_LIGHT=Light
FLEXI_SUBCATEGORY=Subcategory
FLEXI_SUBCATEGORY_DESC=Settings for Subcategories
FLEXI_SUBCATEGORY_COLS=Subcategory Columns
FLEXI_SUBCATEGORY_COLS_DESC=Number of columns to display subcategories in
FLEXI_SHOW_SUBCATEGORY_IMAGE=Show Subcategory Image
FLEXI_SHOW_SUBCATEGORY_IMAGE_DESC=Display the subcategory image instead of the text link
FLEXI_FEATURED_ITEMS=Featured Items
FLEXI_FEATURED_ITEMS_DESC=Settings for Featured Items
FLEXI_SHOW_FEATURED=Show Featured Items
FLEXI_SHOW_FEATURED_DESC=Display the featured items in the template
FLEXI_FEATURED_COLS=Featured Columns
FLEXI_FEATURED_COLS_DESC=Number of columns to display categories in
FLEXI_CATEGORY_ITEMS=Category Items
FLEXI_CATEGORY_ITEMS_DESC=Settings for Category Items
FLEXI_CATEGORY_ITEM_COLS=Category Item Columns
FLEXI_CATEGORY_ITEM_COLS_DESC=Number of columns to display items in
FLEXI_ITEM_DETAIL_COLS=Item Details Columns
FLEXI_ITEM_DETAIL_COLS_DESC=Number of columns in the items details zone

Those modifications and a little more graphics work will yield the result you can see here at SMBBooks.com. Right now what we have is something similar to this:

Not real pretty but getting there. Next time we'll finish the category css, item details display and polish up the graphics a bit.

Comments (0)

Leave a comment

You are commenting as guest.