Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic pages: add class to body for each dynamic path part #640

Open
g105b opened this issue Oct 16, 2023 · 1 comment
Open

Dynamic pages: add class to body for each dynamic path part #640

g105b opened this issue Oct 16, 2023 · 1 comment

Comments

@g105b
Copy link
Member

g105b commented Oct 16, 2023

For example, on URL /shop/computers/apple/macbook-pro

There can be multiple dynamic path parts: page/shop/@shop-area/@brand/@item.html

Currently, the body gets the following classes:

  • dir--page
  • dir--page--shop
  • dir--page--shop--_shop-area
  • dir--page--shop--_shop-area--_brand
  • dir--page--shop--_shop-area--_brand--_item
  • uri--page--shop--_shop-area--_brand--_item

It would also be good to see the following classes, or something similar, so the individual dynamic pages can be referenced in CSS where appropriate:

  • _shop-area--computers
  • _brand--apple
  • _item--macbook-pro
@g105b g105b added this to Backlog in Overview via automation Oct 16, 2023
@g105b
Copy link
Member Author

g105b commented Nov 1, 2023

Can be implemented here:

$dynamicUri = $this->dynamicPath->getUrl("page/");
$dynamicUri = str_replace("/", "--", $dynamicUri);
$dynamicUri = str_replace("@", "_", $dynamicUri);
$this->viewModel->body->classList->add("uri" . $dynamicUri);
$bodyDirClass = "dir";
foreach(explode("--", $dynamicUri) as $i => $pathPart) {
if($i === 0) {
continue;
}
$bodyDirClass .= "--$pathPart";
$this->viewModel->body->classList->add($bodyDirClass);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Overview
Backlog
Development

No branches or pull requests

1 participant