Trying to include small PHP script

Author Message

Alex Jones

Tuesday 09 September 2003 2:35:22 pm

Well, I have tried to follow the directions listed at http://ez.no/developer/ez_publish_3/documentation/customization/tips_tricks/how_can_i_use_my_own_php_script_inside_ezp and am running into problems. For the moment I am trying to do the simplest possible thing: assign a value to a variable. Here is the code I have added to the top of index.php:

ob_start(); # start output buffering
echo "output";# put your output script here
$AlexVariable = ob_get_contents(); # store the output in $variable
ob_end_clean(); # clean output buffering

I have also added {$AlexVariable} to my templates but nothing shows up. I have made sure to clear the caches. What I need to do is a bit more complicated (grabbing some GET variables form the URL), I figured I'd keep it easy. But I am stumped. What am I missing?

Help would be greatly appreciated.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Wednesday 10 September 2003 12:17:41 am

Alex,

There is a better guide at the bottom of that doco for making operators:

http://ez.no/developer/ez_publish_3/documentation/customization/tips_tricks/including_php_files_in_templates

I thought you had coded operators before? What are you trying to do?

Your {$AlexVariable} as it stands will not make into the php. Only via POST or GET will do this. Remember that the template system is itself php code and what you see as html is simply the results of the php code running, so a call of {$AlexVariable} will try and display something that hasn't been set.... Hope this makes sense.

Paul

Alex Jones

Wednesday 10 September 2003 7:47:07 am

I will try the alternate operator idea. What I am trying to do is grab some URL parameters (GET) that are passed to the page which I need to pass to the source attribute of an iframe.

You mention that it would have to use POST or GET, but how do I actually grab those? I tried using:

$SearchQ = $HTTP_GET_VARS['q'];

instead of the echo line, but it doesn't work either. I was hoping for a fast solution to avoid having to write an operator for this, but it appears that I may not have a choice.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Wednesday 10 September 2003 8:14:44 am

Have you had a look at Paul B's ezenv contribution? It may be of use to you in this case.

Paul

Alex Jones

Wednesday 10 September 2003 8:37:15 am

I took a look at it, but as it requires that ViewCaching be disabled it isn't a viable option. The alternate PHP insert instructions are great and I was able to add it. The problem is, I am unable to grab the variables in the URL of the page from within the inserted script. Perhaps they are being translated/stripped by eZ Publish?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Borgermans

Wednesday 10 September 2003 8:41:54 am

>I took a look at it, but as it requires that ViewCaching
>be disabled it isn't a viable option.

Correct, i only use it in only one occasion where I have no other option.

>The problem is, I am unable to grab the variables in
>the URL form the isnerted script. Perhaps they are
>being translated by eZ Publish?

No, the problem is that the content (including post/get variables if any) do not reach your script: its in the view cache. It will only work the first time with a cleared cache.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alex Jones

Wednesday 10 September 2003 11:17:18 am

Ahhh, that makes sense. :) Thanks for the explanation Paul.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

John Mina

Wednesday 26 May 2004 1:36:29 am

HI Alex, Hi Paul
Actually i am trying to get a variable through get method i have the variabel written in the address bar as ?part=2

i want to this variable in the article tpl. i read the words you wrote above here, but i felt lost:(
also when i read the 2 links

can you please let me knwo in simple way how to do it , as i am not PHP expert. i have to admit this
so pelease help
Thanks
Sincerely
John Mina

Tony Wood

Wednesday 26 May 2004 2:31:20 am

Try the callme function.

Code can be found here http://pubsvn.ez.no/community/trunk/extension/callme/
Readme is here http://pubsvn.ez.no/community/trunk/extension/callme/readme.txt

We have been using this method until eZ enable this feature by default

tony
--
http://www.visionwt.com

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

John Mina

Wednesday 26 May 2004 3:12:51 am

hi Tony
i do appricaite your try to help me
but where could i downlaod the module from to extract it, or jsut save the php fiels?
can u please do me a favour, i needto pass a parameter, with an integer value through the get method.
can u please write simple steps to follow

John Mina

John Mina

Wednesday 26 May 2004 3:34:00 am

HI Tony,
I activated the extension you sent me
so now?
how would icustomize the callme extension to enable me pass this value
Sincerely

Tony Wood

Wednesday 26 May 2004 4:56:06 am

All you do is add the ?about=test to your button or link and then you can gather it using the callme module.
Here is an example of its use on a "callme" button

Context: http://www.pobox.co.uk/index.php/services/isp/email_accounts/email_mailboxes
Callme Page: http://www.pobox.co.uk/callme/callme?about=Email%20Mailboxes

The code is tiny but you can modify it to get the effect you need. I would ask that if you add functionality to it please submit the changes so we can all benefit.

I hope this helps

tony
--
http://www.visionwt.com

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:13:51
Script start
Timing: Jan 18 2025 16:13:51
Module start 'layout'
Timing: Jan 18 2025 16:13:51
Module start 'content'
Timing: Jan 18 2025 16:13:52
Module end 'content'
Timing: Jan 18 2025 16:13:52
Script end

Main resources:

Total runtime0.6823 sec
Peak memory usage4,096.0000 KB
Database Queries90

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 589.3438152.6250
Module start 'layout' 0.00620.0034 741.968839.4453
Module start 'content' 0.00960.6713 781.4141771.9063
Module end 'content' 0.68100.0013 1,553.320324.1563
Script end 0.6822  1,577.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4937160.0002
Check MTime0.00130.1911160.0001
Mysql Total
Database connection0.00060.090710.0006
Mysqli_queries0.595587.2815900.0066
Looping result0.00080.1171880.0000
Template Total0.649595.220.3248
Template load0.00180.265020.0009
Template processing0.647794.935220.3239
Template load and register function0.00010.013910.0001
states
state_id_array0.00120.182410.0012
state_identifier_array0.00070.102520.0003
Override
Cache load0.00180.2565900.0000
Sytem overhead
Fetch class attribute can translate value0.00060.084250.0001
Fetch class attribute name0.00100.1439150.0001
XML
Image XML parsing0.00160.227850.0003
class_abstraction
Instantiating content class attribute0.00000.0054190.0000
General
dbfile0.00100.1446290.0000
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
13content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 54
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs