Hi,
I just installed CMSMS, an I was wondering how to pass arguments to my functions.
I've never used a CMS before so I'm unfamiliar with tags like {myfunction}
I know I could pass the vars to the function within the custom tag, but I want my code to be reuseable.
dummy tag {myfunction}:
myfunction($var1,$var2,$var3){
//do your magic
}
thx
CD
custom tags help
Re: custom tags help
If you do: {myfunction name="value"}, you can get that from your plugin with $params['name'];
Is that what you mean?
Is that what you mean?
-
Silverviper
Re: custom tags help
Hi
i want to call my function inside the {myfunction} tag
with plain php i would do like this:
and in my template
hope this helps to answer my question
thx
Chris
i want to call my function inside the {myfunction} tag
with plain php i would do like this:
and in my template
hope this helps to answer my question
thx
Chris
Re: custom tags help
Try this in your user defined tag:
$var1 = "Hello World";
$smarty->assign('var1', $var1);
and in the template or page use:
{$var1}
to output the value ...
Regards,
Nils
$var1 = "Hello World";
$smarty->assign('var1', $var1);
and in the template or page use:
{$var1}
to output the value ...
Regards,
Nils
-
Silverviper
Re: custom tags help
Hi,
ok lets give it one more try,
here's my real function, it may give you a better understanding of my problem
function usage in a non CMSMS page
what i have done so far is to put the asciime function in my custom
tags and named it {antiharvester} without the tags of course.
I have tried what you guys suggested but no luck.
put this in my template {antiharvester tag="mailto:" user="yourname" at="@" domain="yourdomain"}
and put this within the asciime function in my custom tag {antiharvester}
thx
Chris
ok lets give it one more try,
here's my real function, it may give you a better understanding of my problem
Code: Select all
<?
function asciime($tag, $user, $at, $domain){
$myarray = array($tag,$user,$at,$domain);
$a=0;
foreach ($myarray as $new) {
$i=0;
do {
$codechar = substr($new,$i,1);
$code = ord($codechar);
if($code == "�"){
print "";
} else {
$myval[$a] = $myval[$a]."&#$code;";
}
$i++;
}
while($codechar != "");
$a++;
}
print '<__script__ language="JavaScript">
var domain = "'.$myval[3].'";
var user = "'.$myval[1].'";
var recipient = user + "'.$myval[2].'" + domain
var makeurl = "'.$myval[0].'" + recipient
document.write(recipient.link(makeurl))
</__script>';
}
?>
Code: Select all
<?
include 'antiharvester.php';
asciime("mailto:","yourname","@","yourdomain.com");
?>
tags and named it {antiharvester} without the tags of course.
I have tried what you guys suggested but no luck.
put this in my template {antiharvester tag="mailto:" user="yourname" at="@" domain="yourdomain"}
and put this within the asciime function in my custom tag {antiharvester}
Code: Select all
$tag = $params['tag'];
$user = $params['user'];
$at = $params['at'];
$domain = $params['domain'];
Chris
Re: custom tags help
So the code for your user defined tag is:
?
Remeber that a user defined tag is actually a function itself, so putting a function inside a function isn't going to work.
Code: Select all
$tag = $params['tag'];
$user = $params['user'];
$at = $params['at'];
$domain = $params['domain'];
$myarray = array($tag,$user,$at,$domain);
$a=0;
foreach ($myarray as $new) {
$i=0;
do {
$codechar = substr($new,$i,1);
$code = ord($codechar);
if($code == "�"){
print "";
} else {
$myval[$a] = $myval[$a]."&#$code;";
}
$i++;
}
while($codechar != "");
$a++;
}
print '<__script__ language="JavaScript">
var domain = "'.$myval[3].'";
var user = "'.$myval[1].'";
var recipient = user + "'.$myval[2].'" + domain
var makeurl = "'.$myval[0].'" + recipient
document.write(recipient.link(makeurl))
</__script>';
Remeber that a user defined tag is actually a function itself, so putting a function inside a function isn't going to work.
-
Silverviper
Re: custom tags help
Hi,
Thx for clarifying that the tag is a function in itself.
I removed function asciime($tag, $user, $at, $domain) and now it works as it should
Thx to all of you for your support
Chris
Thx for clarifying that the tag is a function in itself.
I removed function asciime($tag, $user, $at, $domain) and now it works as it should
Thx to all of you for your support
Chris
Re: custom tags help
If you are trying to create a function for hiding e-mail addresses from spambots, you can also use this one:
{mailto address=$EmailAddress encode="javascript" subject="Hello"}
You will find more useful infos here (the manual):
http://smarty.php.net/manual/en/
or simply read it in the wiki:
http://wiki.cmsmadesimple.org/tiki-inde ... ilto+Links
Regards,
Nils
{mailto address=$EmailAddress encode="javascript" subject="Hello"}
You will find more useful infos here (the manual):
http://smarty.php.net/manual/en/
or simply read it in the wiki:
http://wiki.cmsmadesimple.org/tiki-inde ... ilto+Links
Regards,
Nils

