In my content summary section I will have the same information for each node. I would like to reference an external php file so that down the road if I ever need to change the summary content I don't have to go through each one and manually change it.

I set text format to php code.

In the summary I added:

<?php include("external.php"); ?>

Problem is that I am not seeing the contents of the php file. In fact, I am not seeing any sign of it in my code.

Am I going about this the wrong way?

Edit: I basically want to be able to change some static HTML that needs to belong in the summary field of my nodes if I ever need to without having to go into each node and change it manually. The text will be the same for all my nodes.

  • Is "external.php" within your include path? – Triskelion Apr 11 '13 at 20:42
  • probably not. :) How do I make sure that it is? Right now its in my main theme folder. – Dan Apr 11 '13 at 21:03
  • Why you need extarnal file? – Oleg Sherbakov Apr 11 '13 at 22:20
  • I am going to have hundreds of nodes with the same body text. If I ever have to change that text I don't want to have to go into each node and change it manually. So having that text in an external file would be much easier. It's just static HTML text. Is there a better way? – Dan Apr 12 '13 at 1:12

If you have a custom module for your site, put the file in that module directory, add it to the mymodule.info file,

file[] = external.inc

and put the include statement in the mymodule.module file. Use the model here if you are unfamiliar.

Make the code a function, named for instance mymodule_standard_summary(), and then use:

print mymodule_standard_summary();

in the summary of your nodes. This should get you started.


Rather than trying to embed your code in the page like this:

  // Embedded code
  print $result;

instead you should set it up in a function in your file like this:

function mymodule_standard_summary() {
  // Your code
  return $result;

I hope this makes it a little clearer.

  • I lose you at "make the code a function". Can you help me make it a function? I understand everything else you mention. – Dan Apr 12 '13 at 1:16
  • @Dan - I have updated the answer. – Triskelion Apr 12 '13 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.