Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

html_image
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Wed Apr 23, 2003 8:25 pm    Post subject: html_image Reply with quote

The plugin html_image should be split into two plugins: html_image and xhtml_image. After a closer look to the specs I realized, that on HTML 4.01 strict the trailing slash is not allowed, but on XHTML the argument border is invalid.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Apr 24, 2003 1:55 am    Post subject: Reply with quote

perhaps an attribute will suffice.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 24, 2003 7:26 am    Post subject: Reply with quote

maybe there should be a central configuration for all html_* functions where they can lookup the standards'settings?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Thu May 01, 2003 5:37 pm    Post subject: Reply with quote

messju wrote:
maybe there should be a central configuration for all html_* functions where they can lookup the standards'settings?


That's an idea. Property doctype = SMARTY_HTML; where some defines are needed:

SMARTY_HTML
SMARTY_XHTML
SMARTY_XML
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu May 01, 2003 5:43 pm    Post subject: Reply with quote

hmmm.

One could also create multiple plugin subdirs, one for HTML, one for XHTML, one for PDF etc.

Instead of html_image, html_table, ... use image, table, ....

Then, you set the plugin directory to the style you want. Set compile_id to style.

voila, depending on which library is selected, you get different compilations for each rendering library.
Back to top
View user's profile Send private message
Hinrich
Smarty Rookie


Joined: 18 Apr 2003
Posts: 33

PostPosted: Fri May 02, 2003 11:14 am    Post subject: Reply with quote

boots wrote:
voila, depending on which library is selected, you get different compilations for each rendering library.


In this case the programmer has to choose. Back to the root, I think different plugins (html_image, xhtml_image etc.) are the best solution. Once a site is set up, the core might never changed anymore, but the layout. It is against the structure to force the designer to change the core code or anything else. The only functions the designer should use are the plugins.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri May 02, 2003 6:17 pm    Post subject: Reply with quote

That's the point, it would be code driven. I like ALLOWING the user to select, but the idea is that it would be transparent. The user would always use "table" but the application decides which library renders it (ie. HTML, pdf, etc.)

I'm working on something similar: a library system for modifiers based on a plugin function block. Still toying, but it has promise.

{mod_lib type="html"}
{$Title|b}
{/mod_lib}

{mod_lib type="debug"}
{$Title|b}
{/mod_lib}

The mod_lib default is set by the application as are all the available choices to the template (so if "debug" doesn't exist, it uses the default rendering style).

The neat thing is that I can layer and aggregate these:

{mod_lib type="corporate myapp html"}
{$Title|b}

{mod_lib type="debug"}
{$WeirdOutput|MyStyle}
{/mod_lib}

{/mod_lib}

The "corporate myapp html" causes the modifier to be applied for each style type in order (conceptually [html [myapp [corporate] ] ] where the innermost item is applied first).

So far, it *mostly* works Wink
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun May 04, 2003 11:52 am    Post subject: Reply with quote

my suggestion:

we add two attributes to html_image:
omit_border (default: false)
omit_slash (default: true)

this makes html_image behave "HTML 4.0.1 strict".

then we can add the plugin xhtml_image:
[php:1:14212810df]
<?php

function smarty_function_xhtml_image($params, &$smarty)
{
require_once $smarty->_get_plugin_filepath('function','html_image');
$params['omit_border'] = true;
$params['omit_slash'] = false;
return smarty_function_html_image($params, $smarty);
}

?>
[/php:1:14212810df]

thoughts?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7367
Location: Lincoln Nebraska, USA

PostPosted: Sun May 04, 2003 5:09 pm    Post subject: Reply with quote

How about the opposite logic:

include_border = true/false
include_slash = true/false

Monte
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun May 04, 2003 7:14 pm    Post subject: Reply with quote

yes. positive logic is better than double negation.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Fri Jul 09, 2004 9:38 am    Post subject: Reply with quote

Hi all,

what about some new parameters:

"maxwidth"
"maxheight"

if the current width is lower than the maxwidth take the current width.

if the current width is geater than the maxwidth take the maxwidth.

same to height-parameters.

Greetz
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7367
Location: Lincoln Nebraska, USA

PostPosted: Fri Jul 09, 2004 1:44 pm    Post subject: Reply with quote

make your own modifier?

{html_table ... width=$width|max:200}
Back to top
View user's profile Send private message Visit poster's website
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Mon Jul 12, 2004 8:48 am    Post subject: Reply with quote

oh i dont know this possibility.

THX a lot

it`s something like this, isn`t it?
[php:1:053904e9ed]
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/


/**
* Smarty max modifier plugin
*
* Type: modifier<br>
* Name: max<br>
* Purpose: correct a given number to the max if needed
*
* @param integer
* @param integer
* @return integer
*/
function smarty_modifier_max( $number, $max)
{
if( $number > $max) return $max;

return $number;
}

?>
[/php:1:053904e9ed]
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7367
Location: Lincoln Nebraska, USA

PostPosted: Mon Jul 12, 2004 2:34 pm    Post subject: Reply with quote

That will work, but you also might do some error checking, be sure both values are integers, etc. See some other modifiers for examples.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Jul 12, 2004 2:42 pm    Post subject: Reply with quote

one aspect is missing here. if you don't pass a width to html_image then the width is determined with GetImageSize(). with a modifier like above you cannot say "use the default imagesize but only up to 200px".

just my 2c.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP