Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Custom tag
Nidhi_Agrawal
Hi All,
I want to create cutom tag using which I can get the value from dcr of a particular textarea.
It will be same as <iw_value> tag with an extra functionallity of removing all the <p> or </p> (paragraph) tags from output genrated using tpl file.
Till now I have created the custom tag which gets the value from dcr but I am not able to remove the <p> tags from output.
see below the code for custom tag
in tpl file
<iw_foo name="dcr.content">
in iw.foo.pm file
sub start
{
my $name = $this->get_attrib('name','perl_name');
my $ienc = $this->get_attrib('ienc','macro');
$this->emit_text($name);
this->emit_perl("
iwpt_output\($name);
");
}
Please any one help me in solving this problem.
Find more posts tagged with
Comments
Adam Stoller
I haven't developed any custom tags - so this is a shot-in-the-dark - but looking at the definition of iw_value.pm I see a number of questionable pieces in your code as posted:
sub start{
my($this, $iw_parser, $start_string) =
@_
;
my $name = $this->get_attrib('name', 'perl_name');
my $ienc = $this->get_attrib('ienc', 'macro');
if (!defined $name) {
$this->error(
error_message => "element syntax: <iw_foo name='...'/>\n",
exit_status => 1
);
}
if (!defined $ienc) {$ienc = 'UTF-8';}
# somewhere in here you need to get the value and parse it - possibly in $name?
$this->emit_text($name);
$
this->emit_perl("iwpt_output\($name);");
$this->emit_perl(
qq{
iwpt_output\( $name, "$ienc" );
}
);
}
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Nidhi_Agrawal
I have used this code ....
This is displaying the value using iwpt_output..
But i am not able to retrieve this value (which is printed using iwpt_output function) into another variable ....
Can anyone tell me how can i parse the value..
Pls help me out in doing that..
Thanks in advance
Adam Stoller
From the code snippet that was posted - it looks like the value is already stored in $name - so you could do whatever processing you want to on that variable before using the iwpt_output().
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Nidhi_Agrawal
This line of code
my $name = $this->get_attrib('name','perl_name');
assign the value to $name ..but it is in the form like.
${[iwpt_var_value(scalar($iw_parser->{'iw_xml'}{'data'}{'iw_pt'}{'dcr'}[0][3]{'Paragraph_Text'}[0][3]{'CDATA'}[0][4]))]}[0]
and when i am using iwpt_output ($name)..
it prints the actual value which i have entered in textarea....
But i am not able to take this displayed value(which i have typed on text area) into another variable....
pls help me out in doing that....
Adam Stoller
Hmm - interesting. You *might* be able to do something like:
my $val = iwpt_dcr_value($name);
Though it isn't clear whether or not that will work - it's probably worth a try.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Nidhi_Agrawal
This line
my $val = iwpt_dcr_value($name);
is not working ....
Any other suggestion...
Pls help me ..
--Nidhi
Adam Stoller
Sorry - I'm out of ideas for the time being - and don't have time to try and play with it myself.
I suggest you keep plugging along and/or take a step back and try a different approach perhaps.
If you're lucky, someone else will chime in with some ideas - but I wouldn't count on it.
You *might* be able to get some help from Support ...
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
awizardly
A question on why you want to create a custom tag for tpl's rather than a function in a perl module.
Effectively you want to make a function that removes all <p> and </p> type tags from a string. That should be easy enough to do.
Call this function fix_ptags()
Then why couldn't you use iw_perl in your tpl to do a
$value = iwpt_dcr_value('dcr.content.sometext');
$fixedvalue=fix_ptags($value);
iwpt_output($fixedvalue);
Now that seems like alot where you want to use the values, but wrap that in a function call and it could be cleaner in your template code.
The reason I have a hard time justifying creating a custom tag is that code is subject to underlying api changes without documentation changes by InterWoven.
The value you are getting back from the perl output is from what I can see a node address to the actual value in the document. Which is then later parsed for output when the iw_value tag is actually rendered for values in the tpl. Not something that should be messed with lightly.
I would also ask support whether they would support any change like this, and I haven't heard of many other people trying to make changes like this to the tagging system. Most people use iw_perl to do more advanced processing.
Lee
Organic Inc
http://www.organic.com