PHP and HTML inline together in a block?
Permalink
Ok, I'm new to concrete5. Please forgive me if this is obvious
My goal: to create a chunk of code containing both PHP and HTML that can be used on every page. In this case, I am looking to make the top section of my site which contains the logo, site name, tagline, etc.
I get it that I need to have a stack which contains the blocks that contain my content. Here is the problem: I can't use inline PHP in any block. I need to use inline php, in this case, so that I can get to the logo image by way of the theme path.
Here's my code that I wish to use, so you can see what I mean. Pretty standard stuff.
I don't want to have to paste this in every single page type. I want to have it is ONE place and call it up when I need it.
I am pretty sure this goal of mine is one of the most standard things that any designer will do with any website, so there must be something that I am not seeing. How do I solve this?
My goal: to create a chunk of code containing both PHP and HTML that can be used on every page. In this case, I am looking to make the top section of my site which contains the logo, site name, tagline, etc.
I get it that I need to have a stack which contains the blocks that contain my content. Here is the problem: I can't use inline PHP in any block. I need to use inline php, in this case, so that I can get to the logo image by way of the theme path.
Here's my code that I wish to use, so you can see what I mean. Pretty standard stuff.
<div id="logo"><a href="/"> <img src="<?php echo $this-&>getThemePath(); ?>/images/logo.gif" /> </a></div> <div id="sitetitle"> <h1><a title="Home" href="/">MY SITE NAME</a></h1> <h2>MY TAGLINE</h2> </div> </div>
I don't want to have to paste this in every single page type. I want to have it is ONE place and call it up when I need it.
I am pretty sure this goal of mine is one of the most standard things that any designer will do with any website, so there must be something that I am not seeing. How do I solve this?
Create a new Checkbox attribute (Dashboard > Pages & Themes > Attributes), and whatever you name the handle can be used in the code snippet below. For example, I've named it 'display_my_code'.
If you would prefer to display your code on every page EXCEPT for a selection of pages, do something this:
You can then add your new attribute to a page by editing the page properties.
In version 5.6, $c is a variable automatically provided to you representing the current page.
In version 5.7, you must declare it yourself with $c = Page::getCurrentPage();