Search
Other Articles Field questions
Forum

Get infos of a single article in category block

Yannick Lämmel's Avatar Yannick Lämmel
Hi there,

I have the following problem.
I have an article with Joomla custom fields in Category A. (Name, E-Mail)

Now I am creating a custom blog layout (custom-blog.php) for Category B. In this blog layout I need to get the data out of the custom fields from the article of category A. I do not need to display the article, but I need to use the data (Name, E-Mail) for creating a custom form.

Is it possible to achieve this with Articles Field or with Articles Anywhere?
Maybe I can use the Articles Field in the XML of my custom blog to select the article? That would be perfect.
But I am also open to use Articles Anywhere in the PHP, if that is giving me the inforamtion I need.

If you need further information, feel free to ask.

Kind regards,
Tanja Vogt
Peter van Westen's Avatar Peter van Westen ADMIN
I recommend you use Articles Anywhere.
There you can simply grab the data from that single specific article in Category A.
{article title="My Article A"}[my-name-field] ... [my-email-field]{/article}
Please post a rating at the Joomla! Extensions Directory
Yannick Lämmel's Avatar Yannick Lämmel
Hi Peter,
thank you for your answer.
I tried to use that in my custom-blog.php:

$ansprechart = '{article id="'.$this->params->get('ansprech_ID').'"}[titel:text] [vorname:text] [nachname:text]##[e-mail:value]{/article}';
$ansprech = explode('##', $ansprechart);
$ansprechmail = explode('@', $ansprech[1]);

But I cannot work with the variables. A war dump for $ansprech is giving me this result, which is correct.
array(2) {
[0]=>
string(60) "Dr. Prof. Max Mustermann"
[1]=>
string(24) ""
}
But $ansprechmail looks like:
array(1) {
[0]=>
string(24) "[e-mail:value]{/article}"
}

And even with $ansprech[0], where the var_dump looked good, I cannot work any further.
Do you have another idea on how to get the values and use them in the php?
Peter van Westen's Avatar Peter van Westen ADMIN
No, that won't work. Articles Anywhere does not get executed before your PHP code is run.
The reason it 'works' in your dump, is that it is then in your HTML output and Articles Anywhere gets run over that output at a later stage.

So no, you cannot use the plugins to get stuff into your PHP variable like that.

Why do you need it in your PHP? What is your end goal?
Please post a rating at the Joomla! Extensions Directory
Yannick Lämmel's Avatar Yannick Lämmel
Hi Peter,

we are creating a category for job offers which displays a form to apply under each job. In the single article layout I used articles field to select both the location and the contact for this job. The information of both are automatically used to prefill some form fields, e.g. the mail-address and the name the application is send to.

But in the category we also have the possibility to apply initiatively. Therefore I wanted to get the info out of the same articles than I used in the single job article.

But I found a solution. I can use articles field in the category and then I will get the output and can prefill the form with the information.

Thank you very much for your help.
Peter van Westen's Avatar Peter van Westen ADMIN
Ok, happy you found a solution.
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