Proper Syntax For setCustomTemplate()?
Permalink
I know the function is defined like this:
setCustomTemplate(string $btHandle, string $temp)
But what is the proper syntax for the $temp? I would like to assign my custom template located at packages/brp/blocks/content/templates/brp_blog_post.php to a content block.
This does not seem to work:
setCustomTemplate('content', 'brp_blog_post);
What is correct?
setCustomTemplate(string $btHandle, string $temp)
But what is the proper syntax for the $temp? I would like to assign my custom template located at packages/brp/blocks/content/templates/brp_blog_post.php to a content block.
This does not seem to work:
setCustomTemplate('content', 'brp_blog_post);
What is correct?
![enlil](/files/avatars/85571.jpg)
could it be you're missing the last " ' " after brp_blog_post ??
No. I mistyped it for the post. I wish it had been that!
Hi there I think it is
$a->setCustomTemplate('content','templates/your_custom_template.php');
or just
$a->setCustomTemplate('content','your_custom_template.php');
it the .php that will make it work
GB
$a->setCustomTemplate('content','templates/your_custom_template.php');
or just
$a->setCustomTemplate('content','your_custom_template.php');
it the .php that will make it work
GB
Dang. Neither of those combinations did the trick. :(
I wonder if I have something else wrong?
I know the type of block that was created is a content block because
And because when I edit that block, the dialog calls says Edit Content.
But is it really content?
I know brp_blog_post.php is at:
packages/brp/blocks/content/templates/brp_blog_post.php
?
I wonder if I have something else wrong?
$a = new SmartyArea('Main'); $a->setCustomTemplate('content', 'templates/brp_blog_post.php'); $a->display($c);
I know the type of block that was created is a content block because
class SmartyArea extends Area {
And because when I edit that block, the dialog calls says Edit Content.
But is it really content?
I know brp_blog_post.php is at:
packages/brp/blocks/content/templates/brp_blog_post.php
?
ooops I must of hit f5... repost sorry
to find out if is really a content block
what is the name of the block when you go to "add block" menu
Can you add the template manually by using the custom template option in the menu ?
what is the name of the block when you go to "add block" menu
Can you add the template manually by using the custom template option in the menu ?
Yes, when I add a block it's a "content' block.
And also yes, I can apply a custom template, in fact the template I want, to the block after the fact.
I just want to do it "automatically."
And also yes, I can apply a custom template, in fact the template I want, to the block after the fact.
I just want to do it "automatically."
Hmmmm does your smartyArea Class have a setCustomTemplate() function in it that maybe is overriding the Area class ?
I am unfamiliar with this class so if you could post it full source it would be helpful thanks
I am unfamiliar with this class so if you could post it full source it would be helpful thanks
No, the SmartyArea class has no setCustomTemplate Function.
Here's the whole thing:
And thanks for your continued help!
Here's the whole thing:
if (!class_exists('SmartyArea')){ Loader::model('area'); class SmartyArea extends Area { public function display(&$c, $alternateBlockArray = null){ $sp = Loader::helper('smartypants', 'brp'); $c = Page::getCurrentPage(); /* Start buffering, render into the buffer, and then use the buffer's contents to feed to SmartyPants */ ob_start(); parent::display($c, $alternateBlockArray); $html = ob_get_contents(); ob_end_clean(); echo $sp->smartypants($html); } }
Viewing 15 lines of 16 lines. View entire code block.
And thanks for your continued help!
can u send a zip and i will do some testing
Great! What do you need in the .zip?
either the brp package or all the needed helpers and classes
and anything related thanks
and anything related thanks
Here' s the package. Thanks for the help.
cant seem to download it
Hmmmm.
Here's another try...
Here's another try...
k I have done some testing and I think the problem is coming from cache
try this
turn off block cache in the dash board
make sure you have the format
.
add a content block and hit publish it should work now
Now I don't understand why this happens for the content block because for other block type like autonav it works fine with cache turned on
hope this helps
GB
try this
turn off block cache in the dash board
make sure you have the format
$a->setCustomTemplate('content','templates/brp_blog_post.php');
add a content block and hit publish it should work now
Now I don't understand why this happens for the content block because for other block type like autonav it works fine with cache turned on
hope this helps
GB
Dang! Still no joy.
I already had the block cache off, but I checked it again to be sure. And then I cleared the concrete5 cache and my Firefox cache. Same problem.
I'll keep poking at this to see if I can find something else. Thank you for your help, so far!
I already had the block cache off, but I checked it again to be sure. And then I cleared the concrete5 cache and my Firefox cache. Same problem.
I'll keep poking at this to see if I can find something else. Thank you for your help, so far!
Weird cos is it working fine here
Are you trying to set a block template as an area template?
I have never looked in to what you are doing.
From a block controller you can do
I have never looked in to what you are doing.
From a block controller you can do
$blockObject = $this->getBlockObject(); if (is_object($blockObject)) { $blockObject->setCustomTemplate($template); // template handle }