detect the current page inside component

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
mahammadareef
Posts: 54
Joined: 14 Oct 2022, 11:54

detect the current page inside component

Post by mahammadareef » 25 Oct 2022, 05:48

I just want to hide/show some parts of the catalog/home component if we are inside the home page of aimeos , how to get to know that we are inside aimeos home page in the catalog/home component .

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: detect the current page inside component

Post by aimeos » 26 Oct 2022, 07:37

Use the "page-catalog-home" CSS class in the <body> tag to hide/show elements at the home page resp. on other pages.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
mahammadareef
Posts: 54
Joined: 14 Oct 2022, 11:54

Re: detect the current page inside component

Post by mahammadareef » 26 Oct 2022, 10:20

I want to toggle the class 'show' inside one of my component based on the page we are in
I tried this
<body class="{{ $page ?? '' }}">
but the variable $page is not accessible inside the component, its only available in base.blade.php


can u please explain me this step by step ,
Thnk you

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: detect the current page inside component

Post by aimeos » 27 Oct 2022, 14:50

You can only toggle by using the CSS, not by any PHP/Blade variables:

Code: Select all

.show { display: none }
.page-catalog-home .show { display: block }
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
mahammadareef
Posts: 54
Joined: 14 Oct 2022, 11:54

Re: detect the current page inside component

Post by mahammadareef » 28 Oct 2022, 05:03

yeah, this CSS for toggling HTML I can understand, but my problem is different,
think iam inside the component locale/select which can be available for all the pages, I want to detect my current page inside this component and write the condition as, if this page is home then do this or do that ...

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: detect the current page inside component

Post by aimeos » 28 Oct 2022, 06:52

This can't be done inside the component. You would have to add your own HTTP controller classes and in their actions set different configs you can then use inside the component - or create a separate component e.g. for you home page.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply