I am making a website requiring different sets of quotes to appear on different pages. For example, on the home page, I would like that a set of quotes randomly be displayed at a corner. Then in another section, another set of quotes relevant to that section be displayed randomly in a particular location. The random_quote tag, however, can only be used for one set, since it accepts only one filename: quotes.txt, which must be placed at the root directory, and does not accept any parameter. May I request that the functionality of this tag be expanded to accept a text filename (includes pathname) and a webpage id or alias? Many thanks!
random_quote tag
-
scsl
random_quote tag
Hi!
I am making a website requiring different sets of quotes to appear on different pages. For example, on the home page, I would like that a set of quotes randomly be displayed at a corner. Then in another section, another set of quotes relevant to that section be displayed randomly in a particular location. The random_quote tag, however, can only be used for one set, since it accepts only one filename: quotes.txt, which must be placed at the root directory, and does not accept any parameter. May I request that the functionality of this tag be expanded to accept a text filename (includes pathname) and a webpage id or alias? Many thanks!
I am making a website requiring different sets of quotes to appear on different pages. For example, on the home page, I would like that a set of quotes randomly be displayed at a corner. Then in another section, another set of quotes relevant to that section be displayed randomly in a particular location. The random_quote tag, however, can only be used for one set, since it accepts only one filename: quotes.txt, which must be placed at the root directory, and does not accept any parameter. May I request that the functionality of this tag be expanded to accept a text filename (includes pathname) and a webpage id or alias? Many thanks!
-
cyberman
-
scsl
Re: random_quote tag
Yes, that's the one I was refering to when I said:
I understand its php code but I don't know how to modify it to accept parameter for the smarty tag. I could study it but it will take time. If cmsms team can do it, I'd appreciate it!
I need random_quote tag to accept a filename (with path) as a parameter. As of now, it accepts a hard-coded file named "quote.txt" that must reside at the root directory.The random_quote tag, however, can only be used for one set, since it accepts only one filename: quotes.txt, which must be placed at the root directory, and does not accept any parameter. May I request that the functionality of this tag be expanded to accept a text filename (includes pathname) and a webpage id or alias? Many thanks!
I understand its php code but I don't know how to modify it to accept parameter for the smarty tag. I could study it but it will take time. If cmsms team can do it, I'd appreciate it!
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: random_quote tag
This is custom module development as nothing like this exists yet (nobody's written it yet). I wrote the first random quote tag, and it was one of my first CMS projects. it's outdated now.
Might I suggest, that if you have some available funds, you sponsor Ted, or one of the other dev team members to write such a module. This would satisfy your needs, contribute to the CMS community, and compensate a developer for relinquishing his (non work time?) time to do development on a task that he's not necessarily focussed on at the moment.
Just my $0.02
Might I suggest, that if you have some available funds, you sponsor Ted, or one of the other dev team members to write such a module. This would satisfy your needs, contribute to the CMS community, and compensate a developer for relinquishing his (non work time?) time to do development on a task that he's not necessarily focussed on at the moment.
Just my $0.02
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
cyberman
Re: random_quote tag
OK. You said, you want a solution. You said, you understand php code. Try the attached files. Delete .txt before.scsl wrote: I understand its php code
It's a Smarty plugin (not CMSms!) for showing .csv files with templates and has an option to show values randomly.
WARNING: There's NO manual inside !!!
- Attachments
-
[The extension txt has been deactivated and can no longer be displayed.]
-
[The extension txt has been deactivated and can no longer be displayed.]
Last edited by cyberman on Fri Sep 14, 2007 3:09 pm, edited 1 time in total.
-
scsl
Re: random_quote tag
Thank you, calguy. Thank you, cyberman for the attachments. Really appreciate it. It's going to take me a while to read and understand it. But guess what, I tried my hand on the php code of that plug-in tag (function.random_quote.php). It works according to what I want. I added two lines, and commented out one line.
function smarty_cms_function_random_quote($params, &$smarty) {
$delim = "\n";
// $quotefile points to the file that holds the actual quotes
$quotefile = $params['quotefile']; /* added */
if (file_exists($quotefile)) { /* added */
// $quotefile = "quotes.txt"; /* commented out */
$fp = fopen($quotefile, "r");
$contents = fread($fp, filesize($quotefile));
$quote_arr = explode($delim,$contents);
fclose($fp);
srand((double)microtime()*1000000);
$quote_index = (rand(1, sizeof($quote_arr)) - 1);
$herequote = $quote_arr[$quote_index];
return $herequote;
} /* added */
}
Now, if there is no bug, radom_quote accepts a parameter which is the filename of the quote file with its pathname included:
eg, in the same website,
in "musicians" section: {random_quote quotefile='uploads/quotesfiles/quotesmusicians.txt'}
in "poets" section: {random_quote quotefile='uploads/quotesfiles/quotespoets.txt'}
in "sages" section: {random_quote quotefile='uploads/quotesfiles/quotessages.txt'}
Today is my happy day!!
function smarty_cms_function_random_quote($params, &$smarty) {
$delim = "\n";
// $quotefile points to the file that holds the actual quotes
$quotefile = $params['quotefile']; /* added */
if (file_exists($quotefile)) { /* added */
// $quotefile = "quotes.txt"; /* commented out */
$fp = fopen($quotefile, "r");
$contents = fread($fp, filesize($quotefile));
$quote_arr = explode($delim,$contents);
fclose($fp);
srand((double)microtime()*1000000);
$quote_index = (rand(1, sizeof($quote_arr)) - 1);
$herequote = $quote_arr[$quote_index];
return $herequote;
} /* added */
}
Now, if there is no bug, radom_quote accepts a parameter which is the filename of the quote file with its pathname included:
eg, in the same website,
in "musicians" section: {random_quote quotefile='uploads/quotesfiles/quotesmusicians.txt'}
in "poets" section: {random_quote quotefile='uploads/quotesfiles/quotespoets.txt'}
in "sages" section: {random_quote quotefile='uploads/quotesfiles/quotessages.txt'}
Today is my happy day!!
