Search
Other Articles Anywhere questions
Forum

Use id for specific article dynamically

Axel Hartmann's Avatar Axel Hartmann
We use an article custom field named 'partner' managing an ID. Inside this article the code {article}[partner]{/article} displays the value. (369)
Using this ID to show the title of the article with ID = 369 we use the following code {article id="369"}[title]{/article}.
We now want to use the custom fields value (ID) dynamically inside a template system, maybe like "this:partner" -> {article id=this:partner}[title]{/article}.

Is there a way to realize this? Any ideas?
Peter van Westen's Avatar Peter van Westen ADMIN
Try:
{article id="this:partner"}[title]{/article}

See: docs4.regularlabs.com/articlesanywhere/d...rom-specific-article
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
Thanks for your answer Peter. It's exactly what I tried. The custom field named "partner" is a "articleslinked" type field and as layout a custom html is defined. It's just [id]
So when using {article}[partner]{/article} it gives back the ID as expected.
When using this:partner like in your example it gives back 1 (probably the default value from the articleslinked field).

Last solution for us could be a more complex custom html layout with all field infos and html code inside.
Just using [id] would make the template system more modular and flexible.

But maybe there is another option for our case?
Peter van Westen's Avatar Peter van Westen ADMIN
When using the this:... stuff in the filters, it will place the value of that field. Not the rendered output via the layout.
The value of an articleslinked field is actually simply a true or false value.

You can try this you output the rendered field output:
{article}{article-nested id="[partner]"}[title]{/article-nested}{/article}
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
Hmmm, tried your and another approach (see below). But there are no values returned for both codes.

{article}{article-nested id="[partner]"}[title]{/article-nested}{/article}

{article id="{article-nested}[partner]{/article-nested}"}[title]{/article}
Peter van Westen's Avatar Peter van Westen ADMIN
Are you running on Joomla 3 or 4?
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
Joomla 4
Peter van Westen's Avatar Peter van Westen ADMIN
Can you check what the actual html output is of:
{article}[partner]{/article}

Instead of [partner], you might need to do:
[partner:text]
So:
{article}{article-nested id="[partner:text]"}[title]{/article-nested}{/article}
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
Output of {article}[partner]{/article} is 369 (ID of linked article defined in custom HTML).

Output of {article}[partner:text]{/article} is 1 (default value of articleslinked custom field).

Thanks for your weekend work! Let me know, if there is a solution.
Maybe a complex custom html code is needed to solve this for now. 🙁
Peter van Westen's Avatar Peter van Westen ADMIN
Are you sure the output of [partner] is just "369", and not actually "<span class="field-value">369</span>"?
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
You are right, I just looked at the result.
The complete code output is
<span class="field-value ">369</span>
Peter van Westen's Avatar Peter van Westen ADMIN
So the solution would be to create a custom layout, that just outputs the field value, and not that surrounding <span> tag.
See: docs4.regularlabs.com/articlesanywhere/d...s#alternative-layout
Please post a rating at the Joomla! Extensions Directory
Axel Hartmann's Avatar Axel Hartmann
Yes, that's it.

I created an alternate layout for custom fields just outputting the value without the span tag, choose this as default layout in the articles linked custom field options. Using a custom HTML layout with outputting just [id] additionally is the solution for using different article fields of the linked article in a template system like Yootheme Pro.
{article}{article-nested id="[partner]"}[title]{/article-nested}{/article}
{article}{article-nested id="[partner]"}[url]{/article-nested}{/article}
{article}{article-nested id="[partner]"}[image-intro]{/article-nested}{/article}

THANK YOU!
Peter van Westen's Avatar Peter van Westen ADMIN
Happy you have it working 🙂

I assume your example code refers to 3 different content parts.
If not, you can of course combine it into one:
{article}{article-nested id="[partner]"}
[title]
...
[url]
...
[image-intro]
{/article-nested}{/article}
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