Hi,
Assigning text replacements doesn’t seem to work in an conditional environment, seems like a bug as any multiple instance of trying to define a ‘preload_variable’ falters, even though it’s only getting defined once, depending on which statement is true…
For example, I want to populate my path variable based on the conditionals of the entries of my custom fields…
So if the 2nd segment is ‘fruit’ then it’ll populate the link with the {landing_page} variable… If an landing_page doesn’t exist…it will go to it’s related entry (Company) and see if it has a special landing page… (company_secondary_url)…. if it doesn’t have that…. then it will show the {company_url}…. (which will always be there….
My logic is correct, but the ‘preload_replace’ fails…. So starting to think now this may very well be a bug…
{if segment_2 == 'fruit'}
{if fruit_landing_page}
{preload_replace:variable_name="{fruit_landing_page}"}
{if:else}
{fruit_company}
{if fruit_company:company_secondary_url}
{preload_replace:variable_name="{fruit_company:company_secondary_url}"}
{if:else}
{preload_replace:variable_name="{fruit_company:company_url}"}
{/if}
{/fruit_company}
{/if}
{/if}
Link to website: {variable_name}Good to either get this functionality added, or if anyone can assist as to why it wouldn’t work please enlighten me 😊
You’d have to use PHP for this, as you can’t assign variables after the fact, so to speak. (In PHP terms they really behave more like constants.) EE preload_replace variables can only be set at the top of the page and then used further on down the line. (To be honest, the “preload” part sort of gives that away.) To dynamically assign variables you’ll need PHP.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.