Search
Other Articles Field questions
Forum

Use Articles Anywhere and Sourcerer in Articles Field

Marc Pradel's Avatar Marc Pradel
Hi,

I have used already article anywhere in combination with sourcerer for output articles contained product data from j2store.

But when I try to use the code in the article field with the custom html output, the j2store shortcode are not rendered.

Do you have an idea how to fix this.

Here is the example code, which works in a custom module position:

{article [id]}
{source 0}
<?php
$product = F0FTable::getAnInstance('Product', 'J2StoreTable')->getClone();
if($product->get_product_by_source('com_content', [id])) {
$productID = $product->j2store_product_id;
}
?>
<div class="j2store-single-product category-view">
<div class="uk-card uk-card-default uk-card-hover">
<div class="uk-card-media-top">
{if badge}<div class="uk-card-badge">[badge]</div>{/if}
<div class="uk-animation-toggle uk-visible-toggle" tabindex="0">
<div class="uk-inline">
[link]
<?php echo '{j2store}'.$productID.'|thumbnail{/j2store}'; ?>
[/link]
{if overlay-text}
<div class="uk-overlay uk-overlay-default uk-position-bottom uk-animation-slide-bottom uk-invisible-hover">
<p>[overlay-text]</p>
</div>
{/if}
</div>
</div>
</div>
<div class="uk-card-body">
<h2 class="uk-margin-remove-top uk-margin-remove-bottom uk-text-center uk-h3">[title]</h2>
</div>
<div class="uk-card-footer">
<?php echo '{j2store}'.$productID.'|price{/j2store}'; ?>
</div>
</div>
</div>
{/source}
{/article}
Peter van Westen's Avatar Peter van Westen ADMIN
It is probably due to the system plugin ordering. Try changing the ordering of the plugins in question.
See: regularlabs.com/guides/242-plugin-order-is-important
Please post a rating at the Joomla! Extensions Directory
Marc Pradel's Avatar Marc Pradel
Change the order in many different ways, but shortcode still not rendered?!

Also try to use a custom layout via custom value layout like described here: regularlabs.com/guides/1302-how-to-creat...in-articles-anywhere

But when I use the following code only the title is rendered...

custom html area of the article field

{article [id]}[title value_layout="templates/yootheme/html/layouts/com_fields/field/productreference.php"]{/article}

code of productreference.php
<?php
defined('_JEXEC') or die;

if (empty($displayData['values']))
{
   return;
}

$values = $displayData['values'];
$ids    = array_keys($values);

$product = F0FTable::getAnInstance('Product', 'J2StoreTable')->getClone();
if($product->get_product_by_source('com_content', [id])) { 
	$productID = $product->j2store_product_id; 
}


?>

{articles articles="<?php echo implode(',', $ids); ?>"}
	<div class="j2store-single-product category-view">
		<div class="uk-card uk-card-default uk-card-hover">
			<div class="uk-card-media-top">
				{if badge}<div class="uk-card-badge">[badge]</div>{/if}
					<div class="uk-animation-toggle uk-visible-toggle" tabindex="0">
					    <div class="uk-inline">					
			            [link]
			            <?php echo '{j2store}'.$productID.'|thumbnail{/j2store}'; ?>
			            [/link]
			            	{if overlay-text}
				            <div class="uk-overlay uk-overlay-default uk-position-bottom uk-animation-slide-bottom uk-invisible-hover">
				                <p>[overlay-text]</p>
				            </div>
							{/if}
        				</div>
    				</div>
			</div>
			<div class="uk-card-body">
				<h2 class="uk-margin-remove-top uk-margin-remove-bottom uk-text-center uk-h3">[title]</h2>
			</div>
			<div class="uk-card-footer">
		        <?php echo '{j2store}'.$productID.'|price{/j2store}'; ?>
		    </div>
		</div>
	</div>	
{/articles}

But maybe I miss something in the documentation
Peter van Westen's Avatar Peter van Westen ADMIN
This is more of a j2store issue, that seems to only work on articles.
If you are outputting this through Articles Anywhere, you can try switching on the "Force content triggers" setting in the Articles Anywhere system plugin settings.
Please post a rating at the Joomla! Extensions Directory
Marc Pradel's Avatar Marc Pradel
With force content triggers I get a Call to a member function get() on null

But why this code works in custom module position and not in the article field?

I solve the issue with calling the custom field with
<?php echo JHtml::_('content.prepare',$myFields['produkt-verknuepfungen']); ?>
Peter van Westen's Avatar Peter van Westen ADMIN
This is down to when plugins get triggered in the rendering process.
j2store only gets triggered on the content.prepare trigger.
My extensions aso get triggered and work on later stages in the process.

Again, this was/is a j2store issue. Not an Articles Field or Articles Anywhere issue.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription