Did you already seen that since the advent of Joomla 1.6 the blog view has been changed? Let me refresh your memory! In Joomla 1.0 and 1.5 the Leading Articles - the articles on the top of Blog view - where shown on full by default, and for the rest of articles only the Article Intro part was shown. With Joomla 1.6 this has been changed, for all articles in a Blog view is shown only the introtext. You didn't even noticed that, right? Me either, until one of my clients has specifically requested the feature.

How to do it? Actually is easier than you might think, but definitively you need to deal with some PHP code, and use the template overrides. So, let's do this methodically.

1. Create a template override for Blog view

You might actually have one in place, check your template for the templates/[template name]/html/com_content/category/ directory. If you have it, then we will need to modify files found there, if not, create the directory,  then go to /components/com_content/views/category/tmpl/ directory, and copy (at least) these two files in the newly created directory:

blog.php
blog_item.php

If you have in your template override in place allready, then check if these two files are there. If some of them are missing, just copy the missing file there. If you have done this, make a copy of blog_item.php, name it for example blog_full.php, this file will serve as the template for the Leading Articles. The name can vary as you wish, you need an unique name, we will use later the string between _ and the .php, in this case "full".

2. Modify the files

Let's change first the blog.php, wich controls what is shown where. Locate in that this line:

<div class="items-leading">

Depending on the exact version you have, or the template override you use this is around line 50. With couple of lines below you will find the line we need to modify. Here is shown the default code for Joomla 2.5.9, use it as a guide!

<div class="items-leading">
    <?php foreach ($this->lead_items as &$item) : ?>
        <div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
            <?php
                $this->item = &$item;
                echo $this->loadTemplate('item');

The last line is the one we will modify. Edit it to look like this - or comment it out, and add this line:

                echo $this->loadTemplate('full');

The "full" in the above line is the string in the newly created template file's name. Basically with this line we instruct Joomla to load the newly created template override to show the Leading Article. Save the file, we are done this part.

The more complicated thing is to tweak the blog_full.php file. Open it! Locate this line:

JHtml::_('behavior.framework');

It's somewhere around line 19. Add after that line this code:

$itemID =  $this->item->id;
$db =& JFactory::getDBO();
$query = "
        SELECT `fulltext`
        FROM `#__content`
        WHERE `id` = $itemID;
        ";
$db->setQuery($query);
$fulltext = $db->loadResult();

The code will load the full text part of the article content. Now we need to show it. Locate this line in the same file:

<?php echo $this->item->introtext; ?>

Add below that this line:

<?php echo $fulltext; ?>

The most important things are now done. what remained is a little cleanup - we need to rip off the useless code. Below the newly inserted code an if statement is started, used for show the Read More button, we don't need it anymore. So, delete the lines from this if, in the default template file there are 30 lines. The first line which should stay is this:

<?php if ($this->item->state == 0) : ?>

And that's all. Save the file, and enjoy the vintage Joomla blog view!

0
0
0
s2sdefault
Category: Template trickery