We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Replace body text based on url segment

How Do I?

scottb's avatar
scottb
343 posts
5 years ago
scottb's avatar scottb

Greetings. Can anyone think of a way to replace a string of text in the body of an entry based on a url segment?

For example, if the url includes X, display text A in the body of the entry. If the URL includes Y, display text B in the body.

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

The examples a little vague, but there are definitely some tools you might look at to see if they’ll help.

First are segment variables, they’ll help with seeing what’s in the URL: https://docs.expressionengine.com/latest/templates/globals/url-segments.html

Second, conditionals. You can do one thing if segment_2 == ‘a’ and another if it == ‘b’: https://docs.expressionengine.com/latest/templates/conditionals.html (you can also use regex in conditionals).

Off hand, I’d think ‘text A’ and ‘text B’ would be different fields- and then it would be easy to show one or the other based on a url segment.

And of course for anything super custom, a custom plugin is always an option.

Hope that gives you some ideas.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.