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

Random text generator

 
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 -> Feature Requests
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Mon Sep 08, 2008 7:26 am    Post subject: Random text generator Reply with quote

<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Random text generator
* Can be useful in:
* Generating the random texts for form validations, check against spams
* Random Password Generation
* @author Bimal Poudel <smarty (at) bimal . org . np>
*
*/
function smarty_function_random($params=array(), &$smarty)
{
$length = !empty($params['length'])?($params['length']+0):5;
if($length>32 || $length<1)
$length=5;

$salt = strrev(md5(mt_rand(1000, 9999).microtime().mt_rand(100, 999)));
$random = substr($salt, 0, $length);
return($random);
}

?>
Back to top
View user's profile Send private message Visit poster's website
charliebbq
Smarty n00b


Joined: 05 Feb 2018
Posts: 4

PostPosted: Mon Feb 05, 2018 11:55 pm    Post subject: Reply with quote

how how do i call these plugin in my .tpl file

i just want 4 random letters every time the page refreshes

thanks
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Feb 07, 2018 12:54 pm    Post subject: Reply with quote

See https://www.smarty.net/docs/en/plugins.tpl
Back to top
View user's profile Send private message
charliebbq
Smarty n00b


Joined: 05 Feb 2018
Posts: 4

PostPosted: Wed Feb 07, 2018 8:03 pm    Post subject: Reply with quote

hi thanks for the link but i know how to install the plugin i just don't know how to call the function in the tpl file

what code do i enter in my .tpl file to get a random letter?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 08, 2018 12:11 am    Post subject: Reply with quote

Read entire chapter.
Back to top
View user's profile Send private message
charliebbq
Smarty n00b


Joined: 05 Feb 2018
Posts: 4

PostPosted: Thu Feb 08, 2018 2:04 pm    Post subject: Reply with quote

i did sorry but don't understand

could you post the code here for me please, just the simple code that will call me 1 random letter in a .tpl file

thanks in advance
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 08, 2018 9:41 pm    Post subject: Reply with quote

What you did not understand?
What you have tried and what does not work for you?
Back to top
View user's profile Send private message
charliebbq
Smarty n00b


Joined: 05 Feb 2018
Posts: 4

PostPosted: Sat Feb 10, 2018 3:19 pm    Post subject: Reply with quote

ok so i added the plugin to the smarty plugin folder

and then in my tpl i tried to call a random char using {$random}
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Feb 10, 2018 4:46 pm    Post subject: Reply with quote

{$random} prints the value of variable "$random". Not calls a plugin {random}.
You should really read the documentation.
Back to top
View user's profile Send private message
umair123
Smarty n00b


Joined: 06 May 2022
Posts: 4

PostPosted: Fri May 06, 2022 8:29 am    Post subject: Reply with quote

However, if the real content is not yet available, using dummy filler text is a popular way to fill those spaces. Nowadays, text generators are becoming popular aside from the traditional FBsymbols generators.
It offers a quick and easy way to fill that empty space on your website design and make sure everyone understand to see the vision you have created.
Furthermore, filler texts are important to see the relative weight of the text on the page in proportion to the other design elements.
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 -> Feature Requests 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