Jump to content

Condition - If Contains Portion of Url Segment


Recommended Posts


I would like to output content on a template at the url /events/, but not /events/?publish_from=2021-08-24&publish_until=2021-08-31. Tried using the wildcard character as referenced here, but no dice.

Does anyone know to achieve this?

$segmented_events = $input->urlSegment('publish_(*)');
if(!$segmented_events) {
	// output only on /events/


Link to comment
Share on other sites

59 minutes ago, Rudy said:

@jds43 urlSegment will not capture URL query strings. If you want something like that, you might want to use $_SERVER['query_string'] output for your if condition.

.. or you can use $input->get() check docs here: https://processwire.com/api/ref/wire-input/get/

if you want to learn how to use ulrSegments, read this: https://processwire.com/docs/front-end/how-to-use-url-segments/

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...