Block level PHP vs Page default PHP
Permalink
Does anyone have any thoughts as to what is preferable?
I need to build a page type which has a avatar image which generates depending on who the page owner is. I had this working with a simple PHP block added to a global area which looked up the page owner ID and gets the avatar image.
But I now see that the simple php block is only really for development purposes.
The other alternative is to hardcode the php into the page type, is there any real difference?
Thanks!
I need to build a page type which has a avatar image which generates depending on who the page owner is. I had this working with a simple PHP block added to a global area which looked up the page owner ID and gets the avatar image.
But I now see that the simple php block is only really for development purposes.
The other alternative is to hardcode the php into the page type, is there any real difference?
Thanks!
Thanks John, I'll keep an eye out for it. I'm using the designer content block at the moment so will try out changing the PHP to ge the page owner details.
One quick question, my PHP blocks were working well in global areas, but this broke the page when I viewed it in dashboard>pagetypes>defaults. I figure it'll probably do the same if php is added to designer content blocks.
Is there PHP that you know of that will detect if the page view is in default>edit mode ?
btw, I have the your 'magic tabs' and 'Quick attribute view' addons and they're fantastic.
http://www.concrete5.org/marketplace/addons/magic-tabs/...
http://www.concrete5.org/marketplace/addons/quick-attribute-view/...
One quick question, my PHP blocks were working well in global areas, but this broke the page when I viewed it in dashboard>pagetypes>defaults. I figure it'll probably do the same if php is added to designer content blocks.
Is there PHP that you know of that will detect if the page view is in default>edit mode ?
btw, I have the your 'magic tabs' and 'Quick attribute view' addons and they're fantastic.
http://www.concrete5.org/marketplace/addons/magic-tabs/...
http://www.concrete5.org/marketplace/addons/quick-attribute-view/...
In most views you can do:
If you are somewhere that $c is not already set:
** This code is from my leaky memory, so you may need to tweak the syntax and method names.
if ($c->isEditMode()){ ... }
If you are somewhere that $c is not already set:
$page = Page::getCurrentPage(); if ($page->isEditMode()){ ... }
** This code is from my leaky memory, so you may need to tweak the syntax and method names.
PS. There are examples of this in both the addons you list. I think quick attribute view has some good edit mode styling that I will probably do for Magic Tabs at some point.
Magic Data is now released:
http://www.concrete5.org/marketplace/addons/magic-data/...
http://www.concrete5.org/marketplace/addons/magic-data/...
To do this without writing any php, I have a 'Magic Data' addon in the prb that will (amongst other things) enable you to attach this type of behaviour to an image block by subverting the image displayed depending on the page owner.