What this hack does:It allows you to create a menu item of type
List - Content Section which lists the categories of a specific content section. Except instead of clicking on a category title to view the content items of that category in an ugly table list format, when this hack is enabled you can choose to have the category content items displayed in a blog format like the
Blog - Content Category menu item would display them.
How to implement the hack:Step 1:open file:
components/com_content/content.phpgoto line 631 of function
showCategory()and replace this:
Code:
HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists, $selected, true );
with this:
Code:
$params->def( 'blog_link', 0 );
if ( $params->get( 'blog_link' ) ) {
global $pop;
showBlogCategory( $id, $gid, $access, $pop, $now, $limit, $limitstart );
} else {
HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists, $selected, true );
}
scroll down to line 1202 of function
BlogOutput()and after this:
Code:
case 'content_blog_category':
$description = new mosCategory( $database );
$description->load( (int)$menu->componentid );
break;
insert this:
Code:
case 'content_section':
$description = new mosCategory( $database );
$description->load( $id );
// Dynamic Page Title
$mainframe->SetPageTitle( $description->name );
if ( $header ) { $header = $description->name; }
break;
save the file!
Step 2:open file:
administrator/components/com_menus/content_section/content_section.xmlafter line 126 where you see this:
Code:
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="unpublished" type="radio" default="1" label="Unpublished Items" description="Show/Hide unpublished items for `Publisher` user group and above">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
insert this:
Code:
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="@spacer" type="spacer" default="" label="Blog Category Hack Below" description="" />
<param name="blog_link" type="radio" default="0" label="Link to Blog Categories" description="Make the Category link to a blog instead of a table">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="cat_columns" type="text" size="3" default="1" label="Category Columns" description="When displaying the categories, how many columns to use per row" />
<param name="header" type="text" size="30" default="" label="Page Title" description="Text to display at the top of the page" />
<param name="page_title" type="radio" default="1" label="Page Title" description="Show/Hide the Page title">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="leading" type="text" size="3" default="1" label="# Leading" description="Number of Items to display as a leading (full width) item. 0 will mean that no items will be displayed as leading." />
<param name="intro" type="text" size="3" default="4" label="# Intro" description="Number of Items to display with the introduction text shown." />
<param name="columns" type="text" size="3" default="2" label="Columns" description="When displaying the intro text, how many columns to use per row" />
<param name="link" type="text" size="3" default="4" label="# Links" description="Number of Items to display as Links." />
<param name="orderby_pri" type="list" default="" label="Category Order" description="Order items by catgeory">
<option value="">No, order by Primary Order only</option>
<option value="alpha">Title Alphabetical</option>
<option value="ralpha">Title Reverse-Alphabetical</option>
<option value="order">Ordering</option>
</param>
<param name="orderby_sec" type="list" default="" label="Primary Order" description="Order that the items will be displayed in.">
<option value="">Default</option>
<option value="date">Oldest first</option>
<option value="rdate">Most recent first</option>
<option value="alpha">Title Alphabetical</option>
<option value="ralpha">Title Reverse-Alphabetical</option>
<option value="author">Author Alphabetical</option>
<option value="rauthor">Author Reverse-Alphabetical</option>
<option value="hits">Most Hits</option>
<option value="rhits">Least Hits</option>
<option value="order">Ordering</option>
</param>
<param name="pagination" type="list" default="2" label="Pagination" description="Show/Hide Pagination support">
<option value="0">Hide</option>
<option value="1">Show</option>
<option value="2">Auto</option>
</param>
<param name="pagination_results" type="radio" default="1" label="Pagination Results" description="Show/Hide Pagination Results info ( e.g 1-4 of 4 )">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="image" type="radio" default="1" label="MOSImages" description="Display {mosimages}.">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="description" type="radio" default="0" label="Description" description="Show/Hide the Category Description">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="description_image" type="radio" default="0" label="Description Image" description="Show/Hide the Category Description">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="category" type="radio" default="0" label="Category Name" description="Show/Hide the Category the item belongs to">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="category_link" type="radio" default="0" label="Category Name Linkable" description="Make the Category text a link to the actual Category page">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="item_title" type="radio" default="1" label="Item Titles" description="Show/Hide the items title">
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="link_titles" type="list" default="" label="Linked Titles" description="Make your Item titles linkable">
<option value="">Use Global</option>
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="readmore" type="list" default="" label="Read More" description="Show/Hide the Read More link">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="rating" type="list" default="" label="Item Rating" description="Show/Hide the item rating - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="author" type="list" default="" label="Author Names" description="Show/Hide the item author - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="createdate" type="list" default="" label="Created Date and Time" description="Show/Hide the item creation date - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="modifydate" type="list" default="" label="Modified Date and Time" description="Show/Hide the item modification date - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="pdf" type="list" default="" label="PDF Icon" description="Show/Hide the item pdf button - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="print" type="list" default="" label="Print Icon" description="Show/Hide the item print button - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
<param name="email" type="list" default="" label="Email Icon" description="Show/Hide the item email button - only affects this page">
<option value="">Use Global</option>
<option value="0">Hide</option>
<option value="1">Show</option>
</param>
save the file!
Step 3: (Note: this step is optional, but it fixes the bug that doesn't allow category images to display in the Content Section page and also allows for categories to be displayed in columns using the "Category Columns" field in the menu setup)open file:
components/com_content/content.html.phpgoto function
showCategories() around line 122
and replace the whole function with this:
Code:
function showCategories( &$params, &$items, $gid, &$other_categories, $catid, $id, $Itemid ) {
if(!count($other_categories)) return;
$columns = $params->def( 'cat_columns', 1 );
if ( $columns == 0 ) {
$columns = 1;
}
$col_with = 100 / $columns; // width of each column
$width = 'width="'. intval( $col_with ) .'%"';
echo '<table width="100%" cellpadding="0" cellspacing="0">';
$z = 0;
$total = count($other_categories);
foreach ( $other_categories as $row ) {
$row->name = htmlspecialchars( stripslashes( ampReplace( $row->name ) ), ENT_QUOTES );
if ( $catid != $row->id ) {
if ( !( $z % $columns ) || $columns == 1 ) {
echo '<tr>';
}
echo '<td valign="top" '. $width .'>';
if ( $row->access <= $gid ) {
$link = sefRelToAbs( 'index.php?option=com_content&task=category§ionid='. $id .'&id='. $row->id .'&Itemid='. $Itemid );
?>
<a href="<?php echo $link; ?>" class="category">
<?php echo $row->name;?></a>
<?php
if ( $params->get( 'cat_items' ) ) {
?>
<i>( <?php echo $row->numitems; echo _CHECKED_IN_ITEMS;?> )</i>
<?php
}
// Writes Category Image
if ( $params->get( 'description_cat' ) || $params->get( 'description_cat_image' ) ) {
echo '<br />';
}
if ( $params->get( 'description_cat_image' ) && $row->image ) {
global $mosConfig_live_site;
$link = $mosConfig_live_site .'/images/stories/'. $row->image;
echo '<img src="'. $link .'" align="'. $row->image_position .'" hspace="6" alt="" />';
}
// Writes Category Description
if ( $params->get( 'description_cat' ) && $row->description ) {
echo $row->description;
}
} else {
echo $row->name;
?>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&task=register' ); ?>">
( <?php echo _E_REGISTERED; ?> )</a>
<?php
}
echo '</td>';
$z++;
if ( !( ( $z ) % $columns ) || $columns == 1 ) {
echo '</tr>';
} else if ($z >= $total) {
echo '</tr>';
}
}
}
echo '</table>';
}
save the file!
Step 4:Log into the admin backend and goto the menu item that is of type
List-Content Section and edit it. You'll see the blog Category options at the bottom of the Parameters. Select
Link to Blog Categories: "yes".
and save.
Thanks to cronlin for originally posting my hack here:
http://forum.joomla.org/index.php/topic,5895.0.htmlI've since updated this hack to Joomla 1.0.12 as well as added support for category lists in the section display to show description images properly.
I've attached the hacked files for Joomla 1.0.12 below.
Enjoy
-barnett