Home » Forum
NoNumber!

Joomla!® Websites & Extensions
development  -  support  -  consultancy

I try to respond within 48 hours (excluding weekends).
If I haven't responded by then, feel free to post a reminder or bug me via email.

My last reply was: 3 Hours, 12 Minutes ago.

Welcome, Guest
Please Login or Register.    Lost Password?

Passing parameter to included PHP file
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Passing parameter to included PHP file
#8667
Passing parameter to included PHP file 1 Year, 9 Months ago  
Hi

searched up and down the forums for anything similar... no luck

I am using rereplacer and sourcerer to try and create a tag for our office staff to add a special offer item into an article.

[additem]item_code[/additem]

and i want it to replace this with the php code to add to the cart which is in a php file.

I have
\[additem\](.*?)\[/additem\]


and
{source} [[script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"]][[/script]]
[[script type="text/javascript" src="fancybox/jquery.fancybox-1.3.0.pack.js"]][[/script]]
[[script type="text/javascript" src="fancybox/jquery.easing-1.3.pack.js"]][[/script]]
[[link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.0.css" type="text/css" media="screen"]]
[[link rel="stylesheet" href="fancybox/style.css" /]]
[[?php
   $var = \1;
   echo $var;
   //include JPATH_SITE.DS.'mlfsnippets'.DS.'addinc.php';
?]]{/source}



for my search and replace but $var is not being seen in the addinc.php file

Help?

regards
Marco
Marco
Posts: 5
User OfflineClick here to see the profile of this user
Last Edit: 2010/04/21 15:06 By peter.
The administrator has disabled public write access.
 
#8669
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
When using the {source} tags in non-editor fields, use {source 0}...{/source}.

I think the problem is with quotes.
use:
[[?php
   $var = '\1';
   echo $var;
?]]
Peter van Westen
Admin
Posts: 9091
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#8670
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
Thanks for the quick response.

However

the item_code was being echo'ed correctly with and without the '' marks but when $var is being used in the addinc.php file it is failing.

?
Marco
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#8671
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
My apologies

var is visible in PHP file, must be my code elsewhere

thanks
Marco
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#8672
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
ok
Peter van Westen
Admin
Posts: 9091
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#8673
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
Can you have two paramters? or more?

e.g. [mytag]val1 val2 val3[/mytag]

and rereplacer them with
<a href="file.html?a=var1&b=var2&c=var3">hello</a>

or something similar?
Marco
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#8674
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
try:
\[additem\]([^ ]*?) ([^ ]*?) ([^ ]*?)\[/additem\]

Then you can use \1 \2 \3.

The tag will only be matched if it has that syntax (3 vars). To also make it work with only 1 and 2 vars requirs a little more complex code...
Peter van Westen
Admin
Posts: 9091
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#8675
Re: Passing parameter to included PHP file 1 Year, 9 Months ago  
stipulating all 3 is just fine!

thanks again.
Marco
Posts: 5
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Moderators: Peter van Westen
hosting joomla
MaxCDN | Content Delivery Network | Accelerate your site to the max
Open Source Training | Online Joomla! Training and Support