Forums / General / Trying to include small PHP script

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

eZ debug

Timing: Jan 18 2025 11:35:41
Script start
Timing: Jan 18 2025 11:35:41
Module start 'content'
Timing: Jan 18 2025 11:35:42
Module end 'content'
Timing: Jan 18 2025 11:35:42
Script end

Main resources:

Total runtime0.8532 sec
Peak memory usage4,096.0000 KB
Database Queries227

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 587.7109180.8359
Module start 'content' 0.00630.7044 768.5469776.9844
Module end 'content' 0.71080.1424 1,545.5313353.3125
Script end 0.8532  1,898.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.5121210.0002
Check MTime0.00160.1877210.0001
Mysql Total
Database connection0.00060.070110.0006
Mysqli_queries0.749787.87062270.0033
Looping result0.00240.28582250.0000
Template Total0.820996.220.4105
Template load0.00200.238920.0010
Template processing0.818995.973120.4094
Template load and register function0.00010.009710.0001
states
state_id_array0.00080.088310.0008
state_identifier_array0.00070.086520.0004
Override
Cache load0.00200.2400900.0000
Sytem overhead
Fetch class attribute can translate value0.00140.166360.0002
Fetch class attribute name0.00120.1350150.0001
XML
Image XML parsing0.00200.230360.0003
class_abstraction
Instantiating content class attribute0.00000.0043190.0000
General
dbfile0.00240.2756400.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 54
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs