DISCUSSION: Incorrect Itemid-list of possible solutions

Discuss the FAQ's here, and get in touch with the FAQ Team.
User avatar
kenmcd
Joomla! Champion
Joomla! Champion
Posts: 5672
Joined: Thu Aug 18, 2005 2:09 am
Location: California
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kenmcd » Fri Nov 04, 2005 5:18 am

More ItemID discussions . . .

Hack categories.searchbot.php to correct Itemid?
http://forum.joomla.org/index.php/topic,6530.0.html

unanswerable questions?
http://forum.joomla.org/index.php/topic,16412.0.html

recommended method for cross referencing
http://forum.joomla.org/index.php/topic,15253.0.html
██ LibreTraining

Phil_K
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sat Aug 27, 2005 7:54 am
Location: Münster, Germany

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by Phil_K » Wed Nov 09, 2005 10:44 am

Hi.

As these Itemid issus are realy frustrating sometimes, is there any documention how 3rd party components should deal with them? There are some scenarios thingable were components are called by modules without an itemid. So what's best to get an Itemid for the internal generated links ?

Greets
Phil.

User avatar
kenmcd
Joomla! Champion
Joomla! Champion
Posts: 5672
Joined: Thu Aug 18, 2005 2:09 am
Location: California
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kenmcd » Wed Nov 09, 2005 10:51 pm

Another ItemID discussion thread:

itemID
http://forum.joomla.org/index.php/topic,17510.0.html
██ LibreTraining

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Thu Nov 10, 2005 12:19 am

This tip follows on from my previous one about making Category Names linkable in blog listings and on content items.

I'll try to make it short by simply posting the (commented) code. Changes are actually straightforward.

Once again, please correct any errors and point out any implications or trip-wires I have missed. I must admit, I haven't thought through on this one what will happen if you have more than one Blog - Content Section menu link for the same Section, but it can't be worse than the status quo(!)...

So; you can also make Section Names linkable on Content Items. This is extremely useful. Why?

You will have noticed that if you create Table - Content Section menu items in a hidden menu in order to normalize ItemIDs when you are primarily using blog-style listings on your site, this screws up your pathway.

It also screws up active menu highlighting. A Section Blog highlights OK, as does a (child) Category Blog, but you lose the highlighting when you click through to a Content Item, because the Content Item takes its ItemID from the hidden Table - Content Section menu item.

So, ideally, you need to provide an alternative way of showing your visitor where they are in the site - to which section and category the article they are reading belongs.

This is ONLY an issue if you have set up your site in a certain way, using blog listings. It won't apply to everyone, but is quite common.

If you show and make linkable both Section Name and Category Name in the parameters of each of your Content Items, (and assuming you have made the changes in my previous tip,) you effectively have a replacement pathway which works... ALMOST.

Unfortunately, the Section Name link picks up its ItemID from the Table - Content Section menu item in the hidden menu, which is not what we want. We want the link to take us back to our Section Blog listing, which is the visible menu item from which we came to the article.

I made the following changes (which incorporate those from the previous Category Name Link tip - everything is commented):

com_content/content.php

Code: Select all

<?php //Helps forum to do code highlighting - not relevant to solution


// loads the link for Section name
if ( $params->get( 'section_link' ) ) {
	$query = 	"SELECT a.id"
	. "\n FROM #__menu AS a"
	. "\n WHERE a.componentid = ". $row->sectionid.""
	. "\n AND a.type = 'content_blog_section'" /** Kper added this line so that a content_blog_section itemid is
	                           used for this particular link. This ties in with the change to the Category name link, below.
	                           The intention is to use these links as a replacement for the Pathway when using blog listings
	                           togeher with a LIST-SECTION menu item in a hidden menu for ItemID normalization.
	                           */
	;
	$database->setQuery( $query );
	$_Itemid = $database->loadResult();
	// Kper changed task=section to task=blogsection in the next line. See note under Category Name, below.
	$link = sefRelToAbs( 'index.php?option=com_content&task=blogsection&id='. $row->sectionid .'&Itemid='.$_Itemid );
	$row->section = '<a href="'. $link .'">'. $row->section .'</a>';
}

// loads the link for Category name
if ( $params->get( 'category_link' ) ) {
	$query = 	"SELECT a.id"
	. "\n FROM #__menu AS a"
	. "\n WHERE a.componentid = ". $row->catid.""
	;
	$database->setQuery( $query );
	$_Itemid = $database->loadResult();
/** Kper replaced the following $link line with the one below it so that linked category names in section blogs
    and on content items go to a category BLOG listing rather than a category TABLE listing. Otherwise there
    are problems with ItemIDs for the content items. This way, a LIST-SECTION menu item can be published
    and ALL the content item links will pick up their ItemIDs from that.
    If the linked category name is a TABLE rather than a BLOG listing (as it is by default), the content item links
    in it will take their ItemIDs from that TABLE-CATEGORY listing (which will, in fact, get NO ItemID if such a
    menu link is not already published), whilst the content item links in the original section blog will take their
    ItemIDs from either that section blog or (if one is published) the LIST-SECTION menu item for that section.
    Arrrrgh!
    
	$link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $row->sectionid .'&id='. $row->catid .'&Itemid='.$_Itemid );

*/

	$link = sefRelToAbs( 'index.php?option=com_content&task=blogcategory&id='. $row->catid .'&Itemid='.$_Itemid );
	$row->category = '<a href="'. $link .'">'. $row->category .'</a>';
}
EDIT for stupidity: I don't know what I was thinking with this. I have now changed the SQL above from ORDER BY a.type to AND a.type = 'content_blog_section'



com_content/content.html.php

Code: Select all

<?php //Helps forum to do code highlighting - not relevant to solution


/**
* Writes Section  -  class="categorynamelinkable" added by Kper for styling of Section names
*                     when they are displayed on content items
*/
function Section( $row, $params ) {
	if ( $params->get( 'section' ) ) {
			?>
			<span class="categorynamelinkable">
			<?php
			if ( $params->get( 'category' ) ) { echo "Section: "; } //Kper added this line
			echo $row->section;
			// writes separator between Section & Category Name when both are active
			if ( $params->get( 'category' ) ) {
				echo '  > '; // I prefer this to a dash. nbsp is because I have padding on the spans via css
			}
			?>
			</span>
		<?php
	}
}

/**
* Writes Category  -  class="categorynamelinkable" added by Kper for styling of Category names
*                     when they are displayed on content items and in blog listings
*/
function Category( $row, $params ) {
	if ( $params->get( 'category' ) ) {
		?>
		<span class="categorynamelinkable">
		<?php
		if ( !$params->get( 'section' ) ) { echo "Section: "; } //Kper added this line. I know it is a category, not a section, but site visitors will perceive it as a sub-section.
		echo $row->category;
		?>
		</span>
		<?php
	}
}
Hope that is of some use to someone.
Last edited by kper on Tue Nov 29, 2005 2:22 pm, edited 1 time in total.

User avatar
rsphaeroides
Joomla! Ace
Joomla! Ace
Posts: 1369
Joined: Sun Aug 21, 2005 2:57 pm
Location: Colorado, USA
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by rsphaeroides » Sun Nov 13, 2005 1:40 am

Here's one for you.

If I do a search (just the standard search no extended, hack or anything) on "San José" one of the results I get is for contact info for a hotel in San José. Great.  Only problem, when I click on the link in the search result I get the expected contact page except that the title is replaced with the title of a seemingly unassociated content item.

Of course the menu is open to this unassocitated menu item and wouldn't you know it the Itemid is the Itemid of the unrelated content.

Same seems to be true of any contact item that shows up in search results (different random content title and Itemid, but same behaviour.  If I search for "me" one of the results is my contact info but my name has been changed to "X-shop" ???

At least with the Table-Content category I can figure out where the incorrect Itemid is coming from, but this is just wild.
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Sun Nov 13, 2005 9:00 pm

That is bizarre!

Database corrupted somewhere?

My contact items show up in search with an itemid of 0 rather than the one I might wish them to have by virtue of being linked to as a menu item, but I can sort of live with that. I'm afraid I simply can't compete at your observed level of weirdness!  :o

Have you got anywhere with unravelling this?

User avatar
rsphaeroides
Joomla! Ace
Joomla! Ace
Posts: 1369
Joined: Sun Aug 21, 2005 2:57 pm
Location: Colorado, USA
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by rsphaeroides » Mon Nov 14, 2005 1:43 pm

kper wrote: That is bizarre!

Database corrupted somewhere?

My contact items show up in search with an itemid of 0 rather than the one I might wish them to have by virtue of being linked to as a menu item, but I can sort of live with that. I'm afraid I simply can't compete at your observed level of weirdness!  :o

Have you got anywhere with unravelling this?
I don't think the database is corrupted.  I do think I've figured out where the substitute title and Itemid are coming from (not why they're coming from there, but where)

I checked a dozen of these and the title and Itemid that is substituted is for whatever content item has the same integer in the id field of  mos_content as the contact item has in the id field of mos_contact_details.

The Itemid is the value of the integer in the id field of mos_menu where component id equals the integer in the id field of mos_contact_details.

In other words even though the link is displaying contact 2

Code: Select all

option=com_contact&task=view&&contact_id=2
it's getting the Itemid and title from the content with id 2

Don't even know how to begin to untangle this mess though.  I think I'll look into removing the contact items from the search.  Sounds easier than trying to fix this and I'd rather have the search limited to content anyway.
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Mon Nov 14, 2005 3:24 pm

Good plan. I think I will exclude contacts from search too. At least until I have more time to look into this further.

Straightforward: just unpublish the Search Contacts mambot.
Last edited by kper on Mon Nov 14, 2005 5:37 pm, edited 1 time in total.

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Fri Nov 18, 2005 3:58 pm

An annoying little problem with Simpleboard.

Not sure if this applies to Joomlaboard or not. I think the discussbot may have been rewritten...

http://forum.joomla.org/index.php/topic,19398.0.html

peach
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Sep 14, 2005 6:05 pm

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by peach » Thu Nov 24, 2005 4:50 pm

kper,

after hours of searching and reading the entire contents of the internet, I finally found your posts about the missing ItemId issues. Good work!

You seem to understand the workings of it very well.
It appears you found the solution I need, but you posted so much stuff that I'm really confused about what to do.

The problems I am experiencing are mainly with the category inventory page, the page you get when you click the little category link in the section blog.

The item id is lost when you click on any category but the first one I made, the "articles" category gets an ItemId=0.

This can be confirmed visually on my site, when you click on a category link the default template is used rather than the template with the section-specific header image:
http://www.starpodium.com/jessica-simpson/

Do you know how to fix this? Wich one of your code changes do I need to use? I tried doing some magic with section links but it didn't work out.

Thanks a lot for what you have contributed already!
Regards,
peach

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Thu Nov 24, 2005 6:07 pm

Hi Peach,

I had a quick look, but I can't see anything with an Itemid of 0. What exactly am I supposed to be looking for?

I can see that all of your menu links seem to go to the same place, and, although I don't know much about these things, I'm aware of a difference or two between Britney Spears and 50 Cent, so that can't be right, can it? You've got some kind of SEF on though so it is a little difficult to see what should be happening.

Be careful which "fixes" (more, "hacks" and "workarounds" really) you apply - they are not all relevant to all site setups. Some of them might cause you problems rather than solve them if you aren't sure exactly what you are trying to achive...

peach
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Sep 14, 2005 6:05 pm

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by peach » Thu Nov 24, 2005 6:27 pm

kper wrote: Hi Peach,

I had a quick look, but I can't see anything with an Itemid of 0. What exactly am I supposed to be looking for?

I can see that all of your menu links seem to go to the same place, and, although I don't know much about these things, I'm aware of a difference or two between Britney Spears and 50 Cent, so that can't be right, can it? You've got some kind of SEF on though so it is a little difficult to see what should be happening.

Be careful which "fixes" (more, "hacks" and "workarounds" really) you apply - they are not all relevant to all site setups. Some of them might cause you problems rather than solve them if you aren't sure exactly what you are trying to achive...
sorry there seems to be a problem with my server, Illl report back here when it's taken care of.

[edit]it's fixed :)[/edit]

The item ID 0 is assigned to the category called "articles" in every section.
btw I use Xaneon extensions with the site.
Last edited by peach on Thu Nov 24, 2005 6:30 pm, edited 1 time in total.

peach
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Sep 14, 2005 6:05 pm

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by peach » Fri Nov 25, 2005 7:13 pm

with my previous post I meant to say that my server is fixed, my ItemId problem is still there though :-\.
kper do you have an idea of how I can make the ItemId survive through the section blog to the category inventory page?

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Sun Nov 27, 2005 4:57 pm

Sorry I haven't been around for a couple of days.

Your site seems to be coming together nicely, Peach.

Still a little difficult to tell what is going on because of the sef, but I take it it is now working how you want?

Clicking the linked categories takes me to a Table - Content Category type listing, so I presume you haven't applied my hack to change this to a blog listing?

peach
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Sep 14, 2005 6:05 pm

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by peach » Sun Nov 27, 2005 5:29 pm

kper wrote: Sorry I haven't been around for a couple of days.

Your site seems to be coming together nicely, Peach.

Still a little difficult to tell what is going on because of the sef, but I take it it is now working how you want?

Clicking the linked categories takes me to a Table - Content Category type listing, so I presume you haven't applied my hack to change this to a blog listing?
I like the table :)
All that is bothering me is that the item ID is lost. (pathwat/templating breaks)

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Sun Nov 27, 2005 6:48 pm

And does it pick up an Itemid if you explicitly publish a Table - Content Category or - Content Section in a hidden menu?

Be aware that blog listings + Itemid normalization usually = messed-up pathway.

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Tue Dec 06, 2005 10:53 pm

When you send a message using the built-in email contact form, it does retain the Itemid in the url through the process; which is good. So this isn't absolutely strictly a tip about Itemid, but it is closely related.

What the form doesn't do is remember anything else. It sends your unsuspecting visitor to
www.yoursite.com/com_contact&Itemid=whatever
after they have submitted the form to send their message, whether they wanted to go there or not.

This is particularly annoying if you did not intend to publish any contact categories or lists, only link to individual contact items via menus.

To fix it, change the code at the bottom of function sendmail in /com_contact/contact.php to read as follows:

Code: Select all

$return = sefRelToAbs( 'index.php?option='. $option .'&task=view&contact_id=' . $con_id .'&Itemid='. $Itemid );
	?>
	<script>
	alert( "<?php echo _THANK_MESSAGE; ?>" );
	document.location.href='<?php echo $return; ?>';
	</script>
	<?php 
}
Unfortunately, this doesn't change the fact that during submission of the form, the visitor temporarily sees
http://www.yoursite.com/com_contact&Itemid=whatever
which is still very annoying...

Is it just me, or does the contact form need reworking somehow?

Incidentally, I also commented out all the code relating to sending copies and vcards because they seemed potentially problematic security/spam-wise...

User avatar
rsphaeroides
Joomla! Ace
Joomla! Ace
Posts: 1369
Joined: Sun Aug 21, 2005 2:57 pm
Location: Colorado, USA
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by rsphaeroides » Wed Dec 07, 2005 2:22 am

kper wrote:
Is it just me, or does the contact form need reworking somehow?
Does it ever.  It's like something out of the age of pencils and paper.  I agree, there are a number of functionality and security issues, and even looking at the information requested makes me wonder how this ever ended up as part of an internet based CMS...No homepage/website, no cell phone, no ICQ.

But that's probably a topic for a whole other thread. 

Thanks for the fix on the redirect.  I had almost written the whole thing off as completely non fuctional, but I think I might use the e-mailer portion of it since I can now hide the listings.
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Wed Dec 07, 2005 8:57 am

Thanks for your encouragement, rsphaeroides. Posted in Wishlists.

You can get some extra fields using the Contacts XTD component, and indeed some extra features like blog display of contacts, but the send mail code is basically the same, with the same dodgy javascript validation system. (Though with the redirect implemented as a parameter option.)

User avatar
CubaLibre
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Thu Aug 18, 2005 4:08 pm
Location: Austria
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by CubaLibre » Wed Dec 07, 2005 10:22 am

Well, that's not really a surprise as Contacts XTD is "just" an enhanced version of the core component ;)
As I didn't intend to re-write the sendmail functionality it's still using the core function.

The flicker of the main contact site in the backgound is an annoyance, you're absolutely right.

Kurt
Kurt Banfi

http://www.clockbit.com <- Developer of Contacts XTD
http://www.open-sef.org <- Chief Designer ;)

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Wed Dec 07, 2005 12:20 pm

CubaLibre wrote: Well, that's not really a surprise as Contacts XTD is "just" an enhanced version of the core component
As I didn't intend to re-write the sendmail functionality it's still using the core function.
I know. I certainly didn't mean any criticism of your component. Quite the opposite.

User avatar
CubaLibre
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Thu Aug 18, 2005 4:08 pm
Location: Austria
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by CubaLibre » Wed Dec 07, 2005 1:49 pm

kper wrote: I know. I certainly didn't mean any criticism of your component. Quite the opposite.
No offense meant, none taken. I just wanted to point out that I consider this behaviour to be a problem, too.

I'm currently waiting for J!1.1 to be released to migrate the whole component to the new codebase before implementing some extra features.
One of them will be an enhanced fillout form so I might well take a closer look at the validation functionality during the process.

Greets,
Kurt
Kurt Banfi

http://www.clockbit.com <- Developer of Contacts XTD
http://www.open-sef.org <- Chief Designer ;)

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Wed Dec 07, 2005 3:25 pm

Cool!  8)

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Tue Dec 13, 2005 1:51 pm


User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by ianmac » Thu Dec 15, 2005 6:14 am

Hey!

I'm having difficulty following all of this...  could someone please summarize the problem?

Actually, what I'm really interested in is the why and how of the $mainframe->getItemid method. Both from a specification point of view (and kenmcd your comments look like they will be helpful) and from a 'why would I want to use this function?' point of view. I am in the process of documenting the mosMainFrame class and am having difficulty understanding this function.

Thanks,
Ian

audienceone
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 214
Joined: Thu Aug 18, 2005 2:01 pm
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by audienceone » Tue Jan 10, 2006 9:07 am

My problems with Itemid is that it breaks the overall look and feel of a site. I've looked at the code to see why is this so. It appears to me that the template (where the look and feel of the site depends) depends on the Itemid of each individual published menu - where in turn the components will receive its Itemid.

Another problem I encountered was that some components do not properly pass on the Itemid to it's class or functions. The sites i've worked on are doing fine with a simple workaround.

On the root directory or includes directory of the Joomla! system I've "created" a function naming if getItemid2(). And include this file with the index.php of the system.

This function will simple pull from the menu table the ID of the menu (which is the Itemid). And assign it internally as the new Itemid for the component.

Code: Select all

$Itemid = getItemid2('com_mycomponent');
or

Code: Select all

$Itemid = getItemid2($option);
The function will simply be

Code: Select all

function getItemid2($option)
{
global $database;

$database->setQuery("SELECT id FROM jos_menu WHERE link LIKE '%$option%'");
$result = $database->loadResult();

return $result;
}
And on every component I have a problem with Itemid, I simply call on the function before a components switch statement to ensure that the Itemid used will be the one for the component and not the one passed from the URL.

With regards to the code posted above, I do not know if someone already came up with the same solution. And with the other solutions proposed I try them. afaik, the workaround I'm using work for me from 4.5.1 up to todays 1.0.5 and the 1.1 alpha
"Speak your truth quietly and clearly; and listen to others; even the dull and ignorant, for they too have their story
...
If you compare yourself with others you may become vain or bitter, for always there will be greater and lesser person than yourself."

peach
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Sep 14, 2005 6:05 pm

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by peach » Tue Jan 10, 2006 11:54 am

If this (Above) works, I'm soooo grateful,

Where do you paste the function in ??

audienceone
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 214
Joined: Thu Aug 18, 2005 2:01 pm
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by audienceone » Wed Jan 11, 2006 4:57 am

You can create a new file on the root directory of your Joomla! installation. Name it 'workaround.php' and right after

Code: Select all

require_once( 'includes/mambo.php' );
of your index.php add this

Code: Select all

include_once( 'workaround.php' );
and your workaround.php should have this code

Code: Select all

<?
/**
 *   Itemid Workaround
 */

defined( '_VALID_MOS' ) or die();

function getItemid2($option)
{
global $database;

$database->setQuery("SELECT id FROM #__menu WHERE link='%$option%'");
$result = $database->loadResult();

return $result;
}
?>
I need it on a separate file and simply included it with index.php of my Joomla! installation because:
  • When I update my Joomla! setup all I need to do is include the separate file.
  • It'll declare the function as global and will let me use it all throughout the system. Any component that I need to use it, It'll allow me to.
If you use this workaround in a component you're developing (to ensure you get your Itemid correct), just create a new function in your component which will do the same thing and use that function instead (as some components are already doing) or better yet, just make sure your component passes the Itemid to every function/child which generates a link.
"Speak your truth quietly and clearly; and listen to others; even the dull and ignorant, for they too have their story
...
If you compare yourself with others you may become vain or bitter, for always there will be greater and lesser person than yourself."

User avatar
kper
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 198
Joined: Fri Aug 26, 2005 11:09 am

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by kper » Wed Jan 11, 2006 7:19 am

audienceone wrote: or better yet, just make sure your component passes the Itemid to every function/child which generates a link.
Which 3rd party components were you originally having trouble with which led you to implement this solution?

audienceone
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 214
Joined: Thu Aug 18, 2005 2:01 pm
Contact:

DISCUSSION: Incorrect Itemid-list of possible solutions

Post by audienceone » Wed Jan 11, 2006 4:19 pm

The one component that I could remember using this was the old phpBB port done by Adam. As with the current state of his port of phpBB for Joomla, I do not know if he has addressed this one already or Joomla has addressed this issue. I have not taken a peek at 1.1's code either to see if the workaround is still needed. Right now, I only have one site being constantly updated with Joomla updates through "incremental overwrite" which is still using the workaround posted above.

Now that I've posted this. I'll check all the components on that site to see if it has the correct Itemid passed. I'll try.
"Speak your truth quietly and clearly; and listen to others; even the dull and ignorant, for they too have their story
...
If you compare yourself with others you may become vain or bitter, for always there will be greater and lesser person than yourself."


Locked

Return to “FAQ Discussion Board”