View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
![](images/avatars/1410118849474bc5107779b.jpg)
Joined: 19 Apr 2007 Posts: 423
|
Posted: Mon Sep 08, 2008 7:26 am Post subject: Random text generator |
|
|
<?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 |
|
charliebbq Smarty n00b
Joined: 05 Feb 2018 Posts: 4
|
Posted: Mon Feb 05, 2018 11:55 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
charliebbq Smarty n00b
Joined: 05 Feb 2018 Posts: 4
|
Posted: Wed Feb 07, 2018 8:03 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Feb 08, 2018 12:11 am Post subject: |
|
|
Read entire chapter. |
|
Back to top |
|
charliebbq Smarty n00b
Joined: 05 Feb 2018 Posts: 4
|
Posted: Thu Feb 08, 2018 2:04 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Feb 08, 2018 9:41 pm Post subject: |
|
|
What you did not understand?
What you have tried and what does not work for you? |
|
Back to top |
|
charliebbq Smarty n00b
Joined: 05 Feb 2018 Posts: 4
|
Posted: Sat Feb 10, 2018 3:19 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Feb 10, 2018 4:46 pm Post subject: |
|
|
{$random} prints the value of variable "$random". Not calls a plugin {random}.
You should really read the documentation. |
|
Back to top |
|
umair123 Smarty n00b
Joined: 06 May 2022 Posts: 4
|
Posted: Fri May 06, 2022 8:29 am Post subject: |
|
|
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 |
|
|