Keyword

Cant render extrafield in category item view

  • Artonezero Limited
  • Artonezero Limited's Avatar Topic Author
  • Offline
  • New Member
More
8 years 2 months ago #157585 by Artonezero Limited
Replied by Artonezero Limited on topic Cant render extrafield in category item view
installed from zip as normal.

same errors. Dump below:
string(411) "[{"id":"1","value":"10' 3\" - 3.11m"},{"id":"2","value":"4' 0\" - 1.22m"},{"id":"3","value":"-"},{"id":"4","value":"45"},{"id":"5","value":"54 sq ft - 5.2 sq m"},{"id":"6","value":"150-220 hours"},{"id":"7","value":["Suggested Hardware Lists","#","same"]},{"id":"8","value":["Buy the plan","#","same"]},{"id":"9","value":["Download a study plan","#","same"]},{"id":"10","value":["Buy a study plan","#","same"]}]"

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #157594 by Krikor Boghossian
Replied by Krikor Boghossian on topic Cant render extrafield in category item view
It should be an Array and not a string.
You can use json_encode() php.net/manual/en/function.json-decode.php in order to convert it into an array so you can directly print data based on the id's position.

Are you using the default template or an override?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Artonezero Limited
  • Artonezero Limited's Avatar Topic Author
  • Offline
  • New Member
More
8 years 2 months ago #157604 by Artonezero Limited
Replied by Artonezero Limited on topic Cant render extrafield in category item view
Worked, many thanks!

Here's the code for reference:
<td>
			<?php 
			//json_decode the extra_fields string 
			$json = json_decode($this->item->extra_fields); 
			
			// print Length if exists
			if($json[0]!=''): print $json[0]->value; 
	
			endif;?>	 
		</td>
        
		<td>&nbsp;&nbsp;&nbsp;&nbsp;
			<?php 
			
			// print Weight if exists
			if($json[3]!=''): print $json[3]->value; 
	
			endif; ?>	
		</td>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #157612 by Krikor Boghossian
Replied by Krikor Boghossian on topic Cant render extrafield in category item view
Nice to be of assistance :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum