Content item navigation in some places and not others?

a1tsal
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Mon Feb 13, 2006 12:03 am
Contact:

Content item navigation in some places and not others?

Postby a1tsal » Fri Jun 30, 2006 12:58 pm

I would like to have content item navigation in some parts of a site (e.g. a blog of news) but not others (e.g. a category of articles that have no inherent ordering).

It appears that this is controlled only by the Global Configuration; but there seems to be no good reason for that.  The other content options in Global Configuration are merely defaults that can be over-ridden by a menu item.

More generally, it seems that there are various non-orthogonalities in the options available for displaying content.  If these are accidental, I'd like to suggesting fixing them.

Thanks!

a1tsal
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Mon Feb 13, 2006 12:03 am
Contact:

Re: Content item navigation in some places and not others?

Postby a1tsal » Fri Aug 04, 2006 8:42 am

Well, I did a patch for this.

In components/com_content/content.php,

changed the line:

Code: Select all

$params->set( 'item_navigation', $mainframe->getCfg( 'item_navigation' ) );

to

Code: Select all

$params->set( 'item_navigation', item_navigation_for ( $row->id ) );

and added a new function:

Code: Select all

function item_navigation_for ( $id ) {
  global $database;
  $query = "SELECT catid FROM #__content WHERE id = $id";
  $database->setQuery( $query );
  $cat_id = $database->loadResult();
  $query = "SELECT item_navigation FROM #__categories WHERE id = $cat_id";
  $database->setQuery( $query );
  return (boolean) ($database->loadResult());
}

This allows control of content item navigation (i.e. previous/next links) on a per-category basis.

It's driven off the jos_categories table, for which I added an extra boolean field "item_navigation".  To do that, you can use phpMyAdmin, or the SQL is

Code: Select all

ALTER TABLE `jos_categories` ADD `item_navigation` BOOL NOT NULL DEFAULT '0';

Then I used phpMyAdmin to set this field to 1 in the categories where I wanted item nav.  There were only two of those, so defaulting to 0 was the right thing.

To make this clean, you'd want to add a field in the category administrator, but I'm happy enough to use phpMyAdmin, because it will be rare for me to want to turn on item navigation in a category.

Frankly, I find it hard to imagine a scenario in which you'd want to have item navigation turned on globally.

johnnybgoodwin
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Apr 27, 2007 3:18 pm

Re: Content item navigation in some places and not others?

Postby johnnybgoodwin » Mon Nov 05, 2007 10:01 pm

Hi There

a1tsal.... I've been looking for ages (along with many others I think) to try and find how to do this... even so, I shied away from your patch, 'cos it does seem a little complicated. Anyway, I did run through this process, using Joomla! 1.0.13 and after all said and done I get an error returned on any content item:

"Call to undefined function: item_navigation_for() in /home/MYHOSTINGACCOUNT/public_html/components/com_content/content.php on line 1468"

I don't really know php, only how to copy and paste :) so any help you or anyone could give to get this working would be better than fantastic!

Cheers!

John
Sing all the earth

AAZ
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jun 25, 2007 7:22 am

Re: Content item navigation in some places and not others?

Postby AAZ » Wed Nov 14, 2007 2:28 am

Got this working nicely. Thanks lots a1tsal.

John, its sounds like your problem is that you've pasted the "item_navigation_for" function in the wrong place (easy mistake if you don't know PHP).

This part:

Code: Select all

function item_navigation_for ( $id ) {
  global $database;
  $query = "SELECT catid FROM #__content WHERE id = $id";
  $database->setQuery( $query );
  $cat_id = $database->loadResult();
  $query = "SELECT item_navigation FROM #__categories WHERE id = $cat_id";
  $database->setQuery( $query );
  return (boolean) ($database->loadResult());
}


needs to be pasted in-between the other functions.  Try pasting it on around line 1547, just before the line

Code: Select all

function show( $row, $params, $gid, &$access, $pop, $option='com_content', $ItemidCount=NULL ) {


It should also be pointed out that this nice little hack doesn't add anything to the interface to let you turn the navigation on and off.  To do this you'll have to edit the entries in the "jos_categories" table in the database.  Find the entry for the category you need navigation turned on and edit the "item_navigation" field from 0 to 1.

johnnybgoodwin
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Apr 27, 2007 3:18 pm

Re: Content item navigation in some places and not others?

Postby johnnybgoodwin » Mon Nov 19, 2007 3:51 pm

Hi AAZ

Thanks for the reply. It worked! (When I remembered to also post the first line of code as well as follow the instruction you posted! Thanks!

Really appreciate your help.

John
Last edited by johnnybgoodwin on Mon Nov 19, 2007 3:59 pm, edited 1 time in total.
Sing all the earth


Return to “Wishlist Archives - Archived”

Who is online

Users browsing this forum: No registered users and 1 guest