"Current page/url is" condition

How can a condition be set to check the current url/path/page/document in App Connect?

For example: Show this component only when the page url == /home or when document name == home.php.

You can use the browser component to check the URL/path. Some examples are provided here:

Thanks @teodor. I expected that the browser component was where this condition could be set, but can’t get the expression right, even not with the information in the How To link. Can you give me an expression example?

Add the browser component in App Structure and its option will be available in the data picker, when you build your condition.

Yes I got that, but building the condition is where I get stuck. Which Browser component data should I use in my expression?


I tried the pathname, referrer, host and others, but I think I got the expression wrong…

What is the exact thing you want to check?

I got an SSI file containing a button that I want to hide on certain pages. So I want to add a dynamic attribute to hide the button when the condition is met that the current url/path/page id of the page where the SSI file content is included equals [domain]/pagename or page.php page_id. I can’t get that expression right however…

Maybe you should use routing for that.

Try enabling routing and use the App Connect Route component.
It has a special match data attribute that will directly match the right path, so you don’t have to do complex route matching yourself

Thanks @George, I tried this too, but as I see it this is a perfect way to include the complete SSI file on certain pages, right? That’s not what I am trying to do. I have the SSI file included on several pages, but want to hide one component of it (a button) on a certain page/url. Hope it’s clear what I am trying to achieve. I think when you understand what I am trying to do it’s an easy case for you guys to create the right expression (probably using the browser component) :slight_smile:

actually not much SSI related.

with the App Connect Route component you are making page areas show/hide dynamically depending on your route/url. I think this is exactly what you want.

Yes, that is what i want to achieve actually…
Can you send an example of this because I really don’t see how. I can set a path for the route component and “Choose an optional content file to include when the route matches”. That way I could include the SSI file contents on certain pages/routes, using the route component on those pages, I can see that. But I can’t figure out how to hide a component from that SSI file (the button I am trying to hide :slight_smile: ) on one single page/route. I think this condition should be set as a dynamic attribute in the SSI that contains the button I want to hide, correct?
Sorry, but I just don’t get it :nerd_face:

you don’t have to choose external file just enter your content inside the route component and give the component a " path" properties when you want it to be active

1 Like

You mean like this, right:

image

Thought I had it working this way, but still not. What am I doing wrong?!

In the path enter the path where this should be displayed.
For example /button

When your main page route is loaded, for example:

yourstite.com/home/ the route will not be loaded.

But if you go to:

yourstite.com/home/button the route will be loaded and you will see the button.

I am so sorry to say it still doesn’t work.

I got these settings for the router component with the notorious button in it:

image

I also got a routing rule setup for this page in de Routes menu:

image

Still, with the button placed in the route component, as shown below, the button shows up on other pages too.

image

The route component and the button are part of an SSI file that is included on the /login path page, amongst others. Could it be that the route component doesn’t work because of that?

You should not enter the /customers/login for the page route …
Just enter / there if you want it to show when the page loads.

I had a case recently where the site owner didn’t want a button to appear if detail pages were accessed via an email rather than via a list view on the site. The button didn’t make much sense if accessed via email, so I simply used:
dmx-show="browser1.referrer.contains("partOfURL")"
… for the button.

Hi @TomD, thanks for your suggestion. Tried that too, unfortunately without success:
dmx-show="router.referrer.contains("'login'")"

I think the problem here is that the button I want to hide is part of a SSI file, which is included in several pages and I only want to hide it on 1 single of those pages. I think checking the url with a condition that is set in the SSI file might be the problem… @Teodor?

I can’t get this working either. The page route is working fine ( [domain]/customers/login is showing the customers/login.php file). And changing the AC route component’s path to ‘/’ doesn’t work.

Sorry, hope it’s not something super stupid on my end why it’s not working… :grimacing: :see_no_evil: