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

Flex Pages: No way to determine page type from blueprint? #3157

Closed
rcheetah opened this issue Jan 19, 2021 · 1 comment
Closed

Flex Pages: No way to determine page type from blueprint? #3157

rcheetah opened this issue Jan 19, 2021 · 1 comment

Comments

@rcheetah
Copy link

rcheetah commented Jan 19, 2021

In the context of a blueprint, there seems to be now way to determine the page type of a page.

Before 1.7 you could tell the type of page by using $blueprint->getFilename(). This would return the type like default or modular or modular/jumbotron etc. But in 1.7 every page has the filename blueprints://flex-objects/pages.yaml, no matter what type of page it is. Therefore you can't extend specific blueprints, you can only extend the global pages blueprint. You can't add new fields only for pages of type 'modular'.

// Grav v1.6.*
public function onBlueprintCreated(Event $event)
{
    /** @var Data\Blueprint $blueprint */
    $blueprint = $event['blueprint'];
    $this->grav['debugger']->addMessage($blueprint->getFilename()); // ->  'default'  ||  'modular'  ||  'modular/text'
}


// Grav v1.7.0-rc
public function onBlueprintCreated(Event $event)
{
    /** @var Data\Blueprint $blueprint */
    $blueprint = $event['blueprint'];
    $this->grav['debugger']->addMessage($blueprint->getFilename()); // -> 'blueprints://flex-objects/pages.yaml'
}
@rcheetah rcheetah changed the title Flex Pages. No way to determine page type from plugin? Flex Pages: No way to determine page type from plugin? Jan 19, 2021
@rcheetah rcheetah changed the title Flex Pages: No way to determine page type from plugin? Flex Pages: No way to determine page type from blueprint? Jan 19, 2021
@mahagr mahagr added 1.7 and removed question labels Jan 20, 2021
@mahagr mahagr added the fixed label May 27, 2021
@mahagr
Copy link
Member

mahagr commented May 27, 2021

@rcheetah The event should now be backwards compatible. Also, the event will now be including $event['type'] and it's being fired only once in admin, see trilbymedia/grav-plugin-flex-objects@bccf43b

@mahagr mahagr closed this as completed Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants