Grabbing block from parent page
Permalink
Hello! I have a silly question. I'm trying to work on an ecommerce website that features a block that will be special based on the category. My question is if it's possible to grab a block (ie. a banner) from a parent page. Soooo for example.....
Clothing
->Shirt
->Pants
Shoes
Accessories
Each will have special banners at the top. The products under each category will be pulling from the top parent. Soo a black top that is located in Clothing > Shirts will be pulling a block from the clothing page. And the Shirts page will of course be pulling from the Clothing page also. I figured there is some way to achieve this and tried researching it, but just not seeing the answer. Help?
Clothing
->Shirt
->Pants
Shoes
Accessories
Each will have special banners at the top. The products under each category will be pulling from the top parent. Soo a black top that is located in Clothing > Shirts will be pulling a block from the clothing page. And the Shirts page will of course be pulling from the Clothing page also. I figured there is some way to achieve this and tried researching it, but just not seeing the answer. Help?
Hey John!
I've played with the Global Area addon, but if you create additional product pages, you gotta go into the page and point it to the correct global area. I wanted to make it where the pages automatically pull the correct banner. Is that not possible? :-S
I've played with the Global Area addon, but if you create additional product pages, you gotta go into the page and point it to the correct global area. I wanted to make it where the pages automatically pull the correct banner. Is that not possible? :-S
It probably is possible by creating a custom view for the Global Area block (you may also have to create a custom controller).
What you would need to do is rather than save/retrieve the page the global area is pulled from in the database, to change it so it got the current page, found its parent, and used that page to pull the global area.
http://www.concrete5.org/documentation/how-tos/developers/change-th...
http://www.concrete5.org/documentation/developers/pages/overview...
(and about half way down)
$page->getCollectionParentID()
What you would need to do is rather than save/retrieve the page the global area is pulled from in the database, to change it so it got the current page, found its parent, and used that page to pull the global area.
http://www.concrete5.org/documentation/how-tos/developers/change-th...
http://www.concrete5.org/documentation/developers/pages/overview...
(and about half way down)
$page->getCollectionParentID()
I had a quick look and hacked the block. This is completely untested. You should be able to install it as a block template at
root/blocks/global_areas/templates/parent_page.php
Let me know if it works and I may package it up as a freebie on the marketplace.
EDIT - an addon for this is now in the PRB, so I have removed the attachment to avoid confusion.
(http://www.concrete5.org/marketplace/addons/parent-area/... - will 404 before it is approved)
root/blocks/global_areas/templates/parent_page.php
Let me know if it works and I may package it up as a freebie on the marketplace.
EDIT - an addon for this is now in the PRB, so I have removed the attachment to avoid confusion.
(http://www.concrete5.org/marketplace/addons/parent-area/... - will 404 before it is approved)
PS. The empty areas test is superfluous and would be removed on a released version.
Hey JohntheFish!
Really appreciate all the help! :)
I created a folder for blocks/global_areas/templates just like you said and placed the parent_area, but it's not doing anything when I try to use the defaults on the page type. Is there something I'm missing? Do I need to override anything in the global_areas plugin?
Really appreciate all the help! :)
I created a folder for blocks/global_areas/templates just like you said and placed the parent_area, but it's not doing anything when I try to use the defaults on the page type. Is there something I'm missing? Do I need to override anything in the global_areas plugin?
You put a global area into the page (or I presume the page type), then select a custom template.
Couldn't resist giving it a go, so ran a few tests and fixed a bug. The attachment to the post has been updated.
- Use the old global areas addonhttp://www.concrete5.org/marketplace/addons/global-areas/... - Its free, so you may as well give it a test drive.
- Put the common content in stacks
- Use the rapid ajax paging addon to load an area from the parent pagehttp://www.concrete5.org/marketplace/addons/rapid-ajax-paging/...