Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
PHP and HTML includes allow you to edit HTML and PHP on one page and update every page that had the include. In Drupal, the path might change with different themes (example: sites/all/themes/yourtheme/includes/head.php)
With the $directory variable, you can easily call the path to your theme. You can create an includes folder, then add your include files in there.
Here's what your Drupal include call will look like:
include ($directory."/includes/head.php");
Comments
won't work when you subtheme
So I did just that and then derived a subtheme from my theme. When I over-rode my page.tpl.php file (which has the includes) Drupal could not find the includes as it expected them to be local to the sub-theme. This was a problem in D6 that I hoped had been fixed in 7 and I really don't want to repeat code in more than one template if it can be included.
Had the same problem with
Had the same problem with Drupal 7.41, $directory was showing my sub-theme. My quick fix was to rewrite the $directory var in template.php.
I need to embed reusable block within HTML page
Hi I need to add include, but I need to add this reusable block inside the article in new post in html format. Would this work or do I have to use php format to include the block?
Do you know if there is a plugin I can use to add a block within admin panel and use shortcode withing html article?
Thank you for your help.