Keyword
Please note that official support for commercial extensions & templates is provided in the Subscriber Help Desk.
Support requests should ONLY be directed there and require an active subscription plan.
This forum board is to be used for archive purposes and knowledge exchange ONLY.

Generating Gallery snippet from K2 extrafield

  • Agence culturelle départementale Dordogne-Périgord
  • Agence culturelle départementale Dordogne-Périgord's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 2 months ago - 9 years 2 months ago #148154 by Agence culturelle départementale Dordogne-Périgord
Generating Gallery snippet from K2 extrafield was created by Agence culturelle départementale Dordogne-Périgord
Hi all,

I'm using K2 and Simple Image Gallery Pro.

Needing specifc display of gallery triggered by an extrafield setting in K2 item, I tried generating a snippet to allow special display of gallery.

My code works well, as I can see : {gallery}users/Retro-test:200:160:0:2::Retroviseur{/gallery} right under my Item's text, but the gallery plugin doesn't seem to pick up this snippet. It does pick it up IF I PUT IT IN PLAIN TEXT IN THE ITEM CONTENT, but not if I use php to generate it like this...

(excerpt of item.php of my K2 template)
<?php if(!empty($this->item->fulltext)): ?>
	<?php if($params->get('itemIntroText')): ?>
		<div class="itemIntroText"> <?php echo $this->item->introtext; ?> 	
		</div>
	<?php endif; ?>
<?php endif; ?>
<?php if($params->get('itemFullText')): ?>
	<div class="itemFullText"> <?php echo (!empty($this->item->fulltext)) ? $this->item->fulltext : $this->item->introtext; ?> 
		<!-- ADDED THIS TO GENERATE GALERY SNIPPET -->
		<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
			<?php if($extraField->value != ''): ?>
				<?php if($extraField->name == 'galerie-retroviseur'): ?><!--- galerie photo spécifique --->
					<?php if($extraField->value != ''): ?>
						<p>&nbsp;</p>
						<p>{gallery}users/<?php echo $extraField->value; ?>:200:160:0:2::Retroviseur{/gallery}</p>
					<?php endif; ?>
				<?php endif; ?>
			<?php endif; ?>
		<?php endforeach; ?>
	</div>
<?php endif; ?>

Using this code, I get my text and the snippet in plain letters.

It seems that I need to concatenate the extrafield value to the items intro/full text and that seems lots more difficult to do.

I guess I'm missing something, or does the sigpro plugin analyse directly the items text BEFORE it get's generated in item.php ?

Where am I going wrong ?

Thank-you for any advice.

Regards
Enzo24
Last edit: 9 years 2 months ago by Agence culturelle départementale Dordogne-Périgord. Reason: typos

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

More
9 years 2 months ago #148215 by Lefteris
Replied by Lefteris on topic Generating Gallery snippet from K2 extrafield
Hi,

You cannot trigger the plugin like that. The plugin tag can be inserted in the extra field as long as you use a recent version of K2. All you have to do is insert the full plugin tag in the extra field value. The only requirement is that the extra field type should be either textfield or textarea.

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

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

  • Agence culturelle départementale Dordogne-Périgord
  • Agence culturelle départementale Dordogne-Périgord's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 2 months ago #148284 by Agence culturelle départementale Dordogne-Périgord
Replied by Agence culturelle départementale Dordogne-Périgord on topic Generating Gallery snippet from K2 extrafield
Thank you for your answer. I was trying to simplify things for site backend users... asking them only the gallery name & having it spit out the chain.. Is there a way to call the plugin and insert my generated coe into it ?
Elses they'll just have to learn the snippet... :/

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

More
9 years 2 months ago #148292 by Lefteris
Replied by Lefteris on topic Generating Gallery snippet from K2 extrafield
Try this:
<?php
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$row = new stdClass;
$row->text = '{gallery}users/'.$extraField->value.':200:160:0:2::Retroviseur{/gallery}';
$dispatcher->trigger('onContentPrepare', array('com_k2.itemlist', &$row, &$this->params, 0));
echo $row->text;
?>

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