Articles Anywhere

dynamic load of custom fields in module

4 months 2 weeks ago #89516

Seppi's Avatar Seppi

Hi

I wanted to load the value of a custom field (kunde) and set a linked to an url from another custom field (link-zu-kunde), if the value of the url field "link-zu-kunde" is not empty .

I tried to do this with the following code:

{article}{if link-zu-kunde > 0}<a href="[link-zu-kunde]" target="_blank" rel="noopener noreferrer">[kunde]</a>{else}[kunde]{/if}{/article}

Unfortunately, this doesn't not work. Seems like the syntax is broken or something... what I get in the module is
www.testurl.com " target="_blank" rel="noopener noreferrer">Kunde

Actually it just should look like
Kunde

(linked with the url from the according custom field)

With your precious help, I realized a dynamic solution for loading the lead-in picture of an article (with an link to the url in the field "url-c", if available):
{article}{if urla > 0}<a href="[urla]" target="_blank" rel="noopener noreferrer">[image-intro]</a>{else}[image-intro]{/if}{/article

And this works just great. I tried to realize my new solution based on this code and I can't see right now, what my mistake could be. Can you?

thank you.

4 months 2 weeks ago #89522

Peter van Westen's Avatar Peter van Westen Admin

Try:

href="[link-zu-kunde output="value"]"
See: www.regularlabs.com/extensions/articlesa...a-tags-custom-fields

4 months 2 weeks ago #89536

Seppi's Avatar Seppi

Hi

Thanks for your suggestions.

With this change, only the full URL is displayed in full, now:

www.testurl.com

instead of the customers name (linked to this url).

And the link behind this URL is wrong
https://ourdomain.com/<a href=

I checked your link to the documentation (thanks!), but I can't find my mistake there.

Do you got another hint for me?

Cheers

4 months 2 weeks ago #89537

Peter van Westen's Avatar Peter van Westen Admin

What does tour full code look like now?
Do you have this online so I can take a look?

4 months 2 weeks ago #89538

Seppi's Avatar Seppi

sorry, problem hast been solved, it's nothing about your extension, I just noticed, my bloody JCE editor ruined the code somehow, as soon as I saved the module.

so the final code for this is

{article}{if kunde > 0}<a href="[link-zu-kunde output="value"]" target="_blank" rel="noopener noreferrer">[kunde]</a>{else}[kunde]{/if}{/article}

thanks!

4 months 2 weeks ago #89539

Peter van Westen's Avatar Peter van Westen Admin

Ok, great.

PS, you can probably just do {if kunde} instead of {if kunde > 0}