HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


php include in templates?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#37963 (In Topic #8541)
Avatar

Fan in training

 How can I get a php code like this into the templates:

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

I would like it somewhere in the footer…

I tried using a block ($block,block=whatever) and bunch of errors appeared…>_> (but the include does sucessfully appear where I want it.)
But because of the errors the site can only load the error pages even though my include in footer is there.


 


Last edit: by Robotical_Computer

~Robo
Back to the top
 
Posted
Rating:
#37993
Avatar

For security/architecture reasons we chose not to allow PHP in templates. The block method should work (which it looks like you're using)…

Make a miniblock in sources_custom/miniblocks/. These are just PHP files named as the block name (e.g. example.php) you want. They contain regular PHP code that output's out what they want to display.

Include it into a template with {$BLOCK,block=example}.

I'm not sure if this is what you're tried, so if it was, please let us know the errors you saw.

It might be that the errors are related to actual bugs in the script. ocPortal has 'PHP notices' turned on, meaning more minor coding errors that might not normally show up, do. To turn those off, put this as the first line of the miniblock:
error_reporting(E_ALL ^ E_NOTICE);


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38020
Avatar

Fan in training

  I turned off the errors in the first line after <?php
And still get bunch of errors when I include the script with the block.
 PHP NOTICE [8] Undefined index: HTTPS (ocPortal version: 3.2.7, PHP version: 5.2.5, URL: /)
 


Last edit: by Robotical_Computer

~Robo
Back to the top
 
Posted
Rating:
#38021
Avatar

Sorry, my suggestion was wrong. ocPortal overrides the PHP error handler, so that won't work. Use this command:

Code

         $GLOBALS['SUPRESS_ERROR_DEATH']=true;


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38023
Avatar

Fan in training

 This is wierd o.O when I add
$GLOBALS['SUPRESS_ERROR_DEATH']=true;
The errors are gone and the text goes all the way from it's where to from the bottom to the top.
Meaning it's not where I put it in the template…

~Robo
Back to the top
 
Posted
Rating:
#38029
Avatar

Can I check you did make a miniblock and not a regular block?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38035
Avatar

Fan in training

  How do you check?

Isn't the location, that determines what it is.. sources_custom/miniblocks

Really don't understand this @_@, it works fine when the errors are showing.
And when I get the errors away, it sudden goes to the top left corner.


Last edit: by Robotical_Computer

~Robo
Back to the top
 
Posted
Rating:
#38037
Avatar

Yes that's a miniblock. It's working for me so I think it must be the code you're using in the miniblock. Can we see it?


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#38068
Avatar

Fan in training

Problem seems to be all fixed, thanks =)

~Robo
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: