Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Short Popup tag

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
datune
Smarty n00b


Joined: 05 May 2003
Posts: 3

PostPosted: Wed Nov 19, 2003 5:53 pm    Post subject: Short Popup tag Reply with quote

I have "extended" the popup function, which enables me to use popups without having to write everything in the {popup} tag.

All i have to do now is {get_popup name="a"} and the caption and text values will be retreived from the current loaded config file.

In the config file:
aCaption = "Some caption"
aText = "The quick brown fox jumps ...."

In a tpl file

{get_popup name="a"}
will be replaced with
{popup caption="Some caption" text="The quick brown fox jumps ...."}

It's just something i found to be usefull, since it allows easy and pleasant reading off all popUp texts. (especially if you start using sections or use different config files).

Just thought i'd share the idea Wink


[php:1:aaa24c5495]<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.get_popup.php
* Type: function
* Name: get_popup
* Version: 1.0
* Date: November 19, 2003
* Author: Jürgen Hauser <mail@jhauser.com>
* Credits: Monte Ohrt <monte@ispi.net>
* Input: name the name of the config variable to retreive
* Purpose: To retrieve the text and optional caption values from
* the currently loaded config file and return the correct popup string.
* In your config file you have to follow the following naming convention:
* Captions have to look like: <name>Caption
* Example: aCaption or bCaption or userCaption or whateverCaption
*
* Text has to look like: <name>Text
* Example: aText or bText or userText or whateverText
*
* Usage: {get_popup name="a"} whereas in your config file you would have :
* aCaption = My Caption
* aText = My Text
* Notes: You can still add all the tags mentioned for the function popup.
* Example: {get_popup name="a" fgcolor="#FF0000'} will still work.
* -------------------------------------------------------------
*/
function smarty_function_get_popup($params, &$smarty)
{
extract($params);

if (!isset($name))
{
return '';
}
$caption = $smarty->get_config_vars($name . 'Caption');
$text = $smarty->get_config_vars($name . 'Text');

if (empty($text) && !isset($inarray) && empty($function)) {
$smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
return false;
}

if (empty($trigger)) { $trigger = "onmouseover"; }

$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
if ($sticky) { $retval .= ",STICKY"; }
if (!empty($caption)) { $retval .= ",CAPTION,'".str_replace("'","\'",$caption)."'"; }
if (!empty($fgcolor)) { $retval .= ",FGCOLOR,'$fgcolor'"; }
if (!empty($bgcolor)) { $retval .= ",BGCOLOR,'$bgcolor'"; }
if (!empty($textcolor)) { $retval .= ",TEXTCOLOR,'$textcolor'"; }
if (!empty($capcolor)) { $retval .= ",CAPCOLOR,'$capcolor'"; }
if (!empty($closecolor)) { $retval .= ",CLOSECOLOR,'$closecolor'"; }
if (!empty($textfont)) { $retval .= ",TEXTFONT,'$textfont'"; }
if (!empty($captionfont)) { $retval .= ",CAPTIONFONT,'$captionfont'"; }
if (!empty($closefont)) { $retval .= ",CLOSEFONT,'$closefont'"; }
if (!empty($textsize)) { $retval .= ",TEXTSIZE,$textsize"; }
if (!empty($captionsize)) { $retval .= ",CAPTIONSIZE,$captionsize"; }
if (!empty($closesize)) { $retval .= ",CLOSESIZE,$closesize"; }
if (!empty($width)) { $retval .= ",WIDTH,$width"; }
if (!empty($height)) { $retval .= ",HEIGHT,$height"; }
if (!empty($left)) { $retval .= ",LEFT"; }
if (!empty($right)) { $retval .= ",RIGHT"; }
if (!empty($center)) { $retval .= ",CENTER"; }
if (!empty($above)) { $retval .= ",ABOVE"; }
if (!empty($below)) { $retval .= ",BELOW"; }
if (isset($border)) { $retval .= ",BORDER,$border"; }
if (isset($offsetx)) { $retval .= ",OFFSETX,$offsetx"; }
if (isset($offsety)) { $retval .= ",OFFSETY,$offsety"; }
if (!empty($fgbackground)) { $retval .= ",FGBACKGROUND,'$fgbackground'"; }
if (!empty($bgbackground)) { $retval .= ",BGBACKGROUND,'$bgbackground'"; }
if (!empty($closetext)) { $retval .= ",CLOSETEXT,'".str_replace("'","\'",$closetext)."'"; }
if (!empty($noclose)) { $retval .= ",NOCLOSE"; }
if (!empty($status)) { $retval .= ",STATUS,'".str_replace("'","\'",$status)."'"; }
if (!empty($autostatus)) { $retval .= ",AUTOSTATUS"; }
if (!empty($autostatuscap)) { $retval .= ",AUTOSTATUSCAP"; }
if (isset($inarray)) { $retval .= ",INARRAY,'$inarray'"; }
if (isset($caparray)) { $retval .= ",CAPARRAY,'$caparray'"; }
if (!empty($capicon)) { $retval .= ",CAPICON,'$capicon'"; }
if (!empty($snapx)) { $retval .= ",SNAPX,$snapx"; }
if (!empty($snapy)) { $retval .= ",SNAPY,$snapy"; }
if (isset($fixx)) { $retval .= ",FIXX,$fixx"; }
if (isset($fixy)) { $retval .= ",FIXY,$fixy"; }
if (!empty($background)) { $retval .= ",BACKGROUND,'$background'"; }
if (!empty($padx)) { $retval .= ",PADX,$padx"; }
if (!empty($pady)) { $retval .= ",PADY,$pady"; }
if (!empty($fullhtml)) { $retval .= ",FULLHTML"; }
if (!empty($frame)) { $retval .= ",FRAME,'$frame'"; }
if (isset($timeout)) { $retval .= ",TIMEOUT,$timeout"; }
if (!empty($function)) { $retval .= ",FUNCTION,'$function'"; }
if (isset($delay)) { $retval .= ",DELAY,$delay"; }
if (!empty($hauto)) { $retval .= ",HAUTO"; }
if (!empty($vauto)) { $retval .= ",VAUTO"; }
$retval .= ');" onmouseout="nd();"';

return $retval;
}

?>[/php:1:aaa24c5495]
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
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