• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 11:31 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Just discovered in the API docs that this popular method is deprecated and scheduled for removal.


Quote:
ProcessTemplateFromData (line 2937)

Given a template in a variable, this method processes it through smarty note, there is no caching involved.

Note: this function is deprecated and scheduled for removal.

deprecated:
final:
access: public

string ProcessTemplateFromData (data $data)

data $data: Input template



Would someone please tell me how to achieve the same result now.

Thanks
psy


Last edited by psy on Sun Aug 19, 2012 2:06 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 11:40 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 3813
Location: The Netherlands
I didn't test myself, but maybe this post gives you a hint?
viewtopic.php?f=3&t=62233&p=284375#p284375

_________________


Top
 Profile  
 
 Post subject: Re: ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 1:04 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Thanks Jos

Calguy's solution only works when you have plain text. It crashes when you have smarty tags within the text. What I want to do is what the old method did, ie evaluate the field contents before returning the output.

I've read (tho probably not fully comprehended) the smarty docs and still can't figure out how to do it.

Any other suggestions?

psy


Top
 Profile  
 
 Post subject: Re: ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 1:10 pm 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 3813
Location: The Netherlands
Where did you actually read that it is deprecated?
It is not stated here http://www.cmsmadesimple.org/apidoc/CMS ... teFromData
and as far as I know that's the official API Doc.

_________________


Top
 Profile  
 
 Post subject: Re: ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 1:33 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Hi Jos

Yes, that's where I read it:


Quote:
ProcessTemplateFromData (line 2937)

Given a template in a variable, this method processes it through smarty note, there is no caching involved.

Note: this function is deprecated and scheduled for removal.

deprecated:
final:
access: public

string ProcessTemplateFromData (data $data)

data $data: Input template


http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#ProcessTemplateFromData


Top
 Profile  
 
 Post subject: Re: ProcessTemplateFromData method in CMSModule
PostPosted: Fri Aug 17, 2012 1:38 pm 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 3813
Location: The Netherlands
Ok.. I had to do a ctrl-F5 :-X

_________________


Top
 Profile  
 
 Post subject: [solved] Re: ProcessTemplateFromData method in CMSModule
PostPosted: Sun Aug 19, 2012 1:22 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Calguy's post helped but it wasn't the full answer. Actually found the solution by reading through the index.php code. There was a comment around line 226

Code:
       // in smarty 3, we could use eval:{content} I think.
       //$html = $smarty->fetch('eval:{content}')."\n";


I got it working in the yet-to-be-released next version SEOTools2 by replacing ProcessTemplateFromData with:

Code:
  $title = $this->GetPreference('title','{title} | {sitename} - {seo_keywords}');
  $title = $smarty->fetch('eval:'.$title);



where $title contained a mixture of text and tags and I didn't want to display the output immediately.

hth
psy


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Sun Aug 19, 2012 2:16 pm 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 3813
Location: The Netherlands
Seems to work just fine, thank you!

But I would also be interested into how to make it backwards compatible to CMSms 1.10?

Also I ask myself why it would be necessary to break plugins and modules for such a little convenient function ???
Maybe the deprecated status on ProcessTemplateFromData could be reconsidered?

_________________


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Sun Aug 19, 2012 2:29 pm 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
A good question for the dev team, along with others like why has "CreateToolTipLink" been deprecated? Very handy little method and the only alternative I found was the cumbersome "CreateLink".


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Sun Aug 19, 2012 2:56 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7132
Location: Fernie British Columbia, Canada
http://www.smarty.net/docs/en/resources.string.tpl

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Mon Aug 20, 2012 12:06 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Thanks Calguy. Understand better now how it works.

FWIW, below are results returned when using the new smarty method to compile the main content block of a page, content_en, programmatically from within a module admin area:

{sitename} : worked correctly and displayed the correct sitename

{title} : compiled but displayed "404 Error"

{cms_module module=News} : compiled and displayed correctly

{news} : returned error "Warning: file(C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatebase.php(147) : eval()'d code) [function.file]: failed to open stream: No such file or directory in C:\wamp\www\xxx\lib\misc.functions.php on line 2263"

{cms_selflink} : compiled and displayed correctly

{custom_copyright} - crashed badly with "Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "2578f763fa0bd97b6b8e3f65fcbab500098a6933" on line 1 "<p>Congratulations! The installation worked. You now have a fully functional installation of CMS Made Simple and you are <em>almost</em> ready to start building your site.<br /><br />{custom_copyright}<br /><br />This is the site name {sitename}<br />this is the title {title}<br /><br />full module tag: {cms_module module=News}<br />plugin form of News tag {news}<br />cms selflink tag: <a href="{cms_selflink href='how-cmsms-works'}">How CMSMS Works</a><br /><br /><br /></p>" unknown tag "custom_copyright"' in C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatecompilerbase.php:656 Stack trace: #0 C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatecompilerbase.php(441): Smarty_Internal_TemplateCompilerBase->trigger_temp in C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 656"

{$myvar} - var assigned in page template out of scope of {content} : did not compile which is understandable however rather than ignoring the var it returned the error "Notice: Undefined index: myvar in C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatebase.php(147) : eval()'d code on line 13

Notice: Trying to get property of non-object in C:\wamp\www\xxx\lib\smarty\sysplugins\smarty_internal_templatebase.php(147) : eval()'d code on line 13
"

In short, seemed that core modules and plugins compiled but any tag that was user related, esp the UDT had problems.

Not passing any comments or judgements, just giving some feedback on results of my testing in the hope they may be useful to dev team.

psy


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Mon Aug 20, 2012 12:19 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7132
Location: Fernie British Columbia, Canada
User defined tags are not loaded in the admin in 1.11

"eval:{content}" and "eval:{content_image}" and other such tags will not work in the admin as there is no concept of a current frontend page when working in the admin.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Mon Aug 20, 2012 12:35 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Good to know. Thanks.

Code being tested was:

Code:
$output .= '<div class="pageinput">'.$smarty->fetch('eval:' . $content_obj->GetPropertyValue('content_en')).'</div>';


Top
 Profile  
 
 Post subject: Re: [solved] ProcessTemplateFromData method in CMSModule
PostPosted: Mon Aug 20, 2012 12:59 am 
Offline
Power Poster
Power Poster

Joined: Sat Jan 22, 2005 11:19 am
Posts: 428
Quote:
User defined tags are not loaded in the admin in 1.11


Does module_custom still work?

There have been occasions in the past when a client has wanted something unique in the admin area of a module and I've used this dir to override the default admin template and included UDTs.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting