- Posts: 15
COMMUNITY FORUM
Reference Tags on home page
- Brian
- 
				Topic Author 
- Offline
- New Member
		Less
		More
		
			
	
		
			
	
						12 years 4 months ago				#113961
		by Brian
	
	
		
			
	
			
			 		
													
	
				Reference Tags on home page was created by Brian			
			
				I'm trying to "sort" through content on the homepage to display particular items based on the "Tags" that are included in them, but I can't figure out how to reference those tags from the home page.
I can reference tags on the item pages with no problem and am using that to display different images, but it doesn't seem to work on the index.php home page.
Here's what I've tried:
Any ideas??
					I can reference tags on the item pages with no problem and am using that to display different images, but it doesn't seem to work on the index.php home page.
Here's what I've tried:
<?php
        echo count($items); //this returns 13, which is the correct number of items
        echo count($item->tags); //this returns 0
        echo $params->get('itemTitle'); //this returns 1
        echo $params->get('itemTags'); //this returns 0
?>Any ideas??
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- 
				
- Offline
- Platinum Member
		Less
		More
		
			
	
		- Posts: 15920
			
	
						12 years 4 months ago				#113962
		by Krikor Boghossian
	
	
		
			
		
				
		
	
		
				
		
	
	
		
	
	
	
	
		
			
					
	
	
	
	
	
	
	
			
						
	
		
	
                    
                
				Replied by Krikor Boghossian on topic Re: Reference Tags on home page			
			
				Hello Brian,
echo $params->get(xxx) will always return 0 or 1 because it is just boolean (check).
For the comments you will have to use a category_item.php override ( assuming your menu item is a K2 categories one.)
You will notice that this template part uses $this->item instead of $item so you will need the variables
	
	echo $params->get(xxx) will always return 0 or 1 because it is just boolean (check).
For the comments you will have to use a category_item.php override ( assuming your menu item is a K2 categories one.)
You will notice that this template part uses $this->item instead of $item so you will need the variables
Log in  or Create an account to join the conversation.
	
		
			 		
													- Brian
- 
				Topic Author 
- Offline
- New Member
		Less
		More
		
			
	
		- Posts: 15
			
	
						12 years 4 months ago				#113963
		by Brian
	
	
		
			
	
			
			 		
													
	
				Replied by Brian on topic Re: Reference Tags on home page			
			
				Thanks Krikor!
I'm actually modifying the code within the default.php template inside mod_k2_content/templ/myCustomTemplate
When I put in:
$this->item->params->get('catItemTags') // If the tags are enabled
echo count($this->item->tags) // the count
It throws the following error:
Fatal error: Using $this when not in object context in C:\xampp\htdocs\joomla25\modules\mod_k2_content\tmpl\unique\default.php on line 20
If I just put in:
echo $params->get('catItemTags'); // it doesn't return anything
Not sure how to create the reference to the tags outside of the item object...
Will keep trying things.
Thanks!
					I'm actually modifying the code within the default.php template inside mod_k2_content/templ/myCustomTemplate
When I put in:
$this->item->params->get('catItemTags') // If the tags are enabled
echo count($this->item->tags) // the count
It throws the following error:
Fatal error: Using $this when not in object context in C:\xampp\htdocs\joomla25\modules\mod_k2_content\tmpl\unique\default.php on line 20
If I just put in:
echo $params->get('catItemTags'); // it doesn't return anything
Not sure how to create the reference to the tags outside of the item object...
Will keep trying things.
Thanks!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- 
				
- Offline
- Platinum Member
		Less
		More
		
			
	
		- Posts: 15920
			
	
						12 years 4 months ago				#113964
		by Krikor Boghossian
	
	
		
			
	
			
			 		
													
	
				Replied by Krikor Boghossian on topic Re: Reference Tags on home page			
			
				Oh I see,
As I told you this code is for the component view not the mod_k2_content. You can alter this code a bit and it should work.
You can use instead $params->get('itemTags') and $item-> instead of $this->item
If you have any doubts you can always open the default module template and view the original code.
					As I told you this code is for the component view not the mod_k2_content. You can alter this code a bit and it should work.
You can use instead $params->get('itemTags') and $item-> instead of $this->item
If you have any doubts you can always open the default module template and view the original code.
Please Log in or Create an account to join the conversation.