Hardcoding content block

Permalink
Hi,

I am trying to hardcode a content block or two into a template (will be the display.php for the ecommerce add-on) as I need to split the content up, I have found a few examples of adding the autonav block this way but can't find an example for the content block.

Many Thanks

Steve

 
Mnkras replied on at Permalink Reply
Mnkras
thats because why bother with coding in the content block... its static content, just add it like html
glowmedia replied on at Permalink Reply
Hi,
thanks for replying, the reason I thought I needed to hardcode a content box is that in the layout I wanted for my product detail page I would like the add to cart button between the description and other text (tech specs for example).

Not sure what you did mean by your answer so if you could please expand on it that would be great.

Thanks

Steve
jordanlev replied on at Permalink Reply
jordanlev
I think the terms are getting confused here. When you say you want to "hardcode a content block", do you mean that you want a piece of content (like some text) to appear on every single page in the site, and it cannot be changed through the CMS (you would have to go to the theme code to change it)? If so, what Mnkras is suggesting is that in your theme's page type template, you just do this:
<h1>Here is a heading. This is just HTML. This is the heading for "hardcoded content"</h1>
<?php
$a = new Area('Inline Cart Link');
$a->display($c);
?>
<p>Here is some more "hardocoded content". It is after the cart link area. It is just plain old html in the page type template. It will appear on every page in the site that uses this page type. It cannot be changed through the CMS. If you want to change it, you have to come to this file and edit it.</p>


Or did you mean something else by "hardcoded" (like "kind of hard-coded by default but can still be changed by users from the CMS"?)

-Jordan
glowmedia replied on at Permalink Reply
Hi Jordan,

it was the second option that I was looking for, where I would like to insert a content block into the product detail layout.

Is this even possible, if not then I will have to design my way out of this issue.

Cheers

Steve
Mnkras replied on at Permalink Reply
Mnkras
The only way is to create an area, or make a global block
tbcrowe replied on at Permalink Reply
tbcrowe
To use a global block add the following code to your page template:
$b = Block::getByName('My Content');
$b->display();

The go to the Dashboard > Scrapbook page and add a content block to the global scrapbook. Change the name of the block to 'My Content'. Change the string 'My Content' in both places to whatever you want.