Change Page/Post/Layout based on URL parameter?

Heya!

I was hoping to be able to leverage the layout builder and some ACF magic to achieve varying content/layouts based on where traffic is coming from (e.g. a landing page visit via SEM vs an onsite page visit) but still retain one single post/page/whatever. Scrolling through the layout conditions, it doesn’t look like there are any sort of string or dynamic content input where I can set this up.

image

Is this a no-go, or do you know an alternative way to feed display condition information to this?

E.g.

https://.../page = Layout A

https://.../page?landing=yes = Layout B

Hello @Rule72,

Thanks for writing in!

A custom layout must be assign to a specific page (group of pages) or archive page. What you have in mind cannot be done by just using the Conditions that we have in the settings. What you can do is to this:
1.) Create a custom single layout
2.) Assign this newly created layout to your “page”
2.) In your layout, you will have to insert a Section (1) for your Layout A
3.) And insert another Section (2) for Layout B

Normally both Sections will display since you have not added a condition in each of the sections yet.

4.) You need to apply a “string” Condition to the Section (1) or Layout A which will be using the URL Parameter {{dc:url:param key="landing" fallback="no"}} dynamic content.

You will have to do similar condition for the Section (2) and this time, the URL parameter must be equal to “YES”.

If you are not familiar with the URL parameter dynamic content, kindly check out this thread:

Best Regards.

Gotcha. I’m guessing this is because a page is generated in the loop (and conditions read the loop to function), but URL parameters are sort of “tacked on” after-the-fact which doesn’t give Cornerstone conditions anything to read in the first place?

The work-around works in general though, thanks!

Hi @Rule72,

Glad that it worked for you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.