Get XOOPS XOOPS FAQ Forums News Themes Modules
New Posts New Topics All Forums Index General Modules Themes Development International XOOPS.org

XOOPS vs. Herko Coomans

Make a donation

Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Search

Local Support Sites

Cumulus Tag Cloud

admin Arabic banner block Christmas comments cumulus DayDawn dhsoft e-Commerce E-Learning Google GUI hacks instant-zero jQuery module news Nordic Olédrion oxygen PageRank security SEO simple-XOOPS sport tag Theme wiki xoops

New Users

Registering user

# 96568

dvsshoescom

Welcome to XOOPS!
XOOPS Code hosted on SourceForge


 Bottom   Previous Topic   Next Topic

#1 Posted on: 2007/2/7 18:18 Pull random quotes from RM Myfolder
Hi there,

I'm using RM soft's MyFolder for my portofolio.
It has a build in field for a comment from the Client about the work.
These comments can be displayed in a block but it isn't random, it takes the last x comments.

Is there an easy way to get it to pull a random quote instead of the last ones?

I think this is the php code from the block:


function rmmf_bk_comments($options){
    
$db =& Database::getInstance();
    
$myts =& MyTextSanitizer::getInstance();
    
$result $db->query("SELECT * FROM ".$db->prefix("rmmf_works")." ORDER BY id_w DESC LIMIT 0,$options[0]");
    
$block = array();
    while (
$row $db->fetchArray($result)){
        
$rtn = array();
        
$rtn['id'] = $row['id_w'];
        
$rtn['titulo'] = $row['titulo'];
        
$rtn['texto'] = $myts->makeTareaData4Show($row['comentario']);
        
$rtn['cliente'] = $row['cliente'];
        
$block['works'][] = $rtn;
    }
    return 
$block;
}

function 
rmmf_bk_comments_edit($options){
    
$form _BK_RMMF_NUMCOMMS."<br /><input type='text' size='5' name='options[]' value='$options[0]' />";
    return 
$form;
}


And this is the block template:


<{foreach item=work from=$block.works}>
<
div style="font-size: 10px; text-align: right;">
    <
span style="font-style: italic;">"<{$work.texto}>"</span><br />
    <
a href="<{$xoops_url}>/modules/rmmf/view.php?id=<{$work.id}>"><{$work.cliente}></a>
</
div><br />
<{/foreach}>


I think it's an easy one if your good with php/mysql, which I'm not

Top


. . . : : : | | | PressureLab.com | | | : : : . . .
bassyard
Not too shy to talk
Joined:
2003/10/5 7:30
From Antwerp, Belgium
Posts: 154
(Show More) (Show Less)
#2 Posted on: 2007/2/7 21:35 Re: Pull random quotes from RM Myfolder
bassyard,

I think the following code will do what you want if you replace the functions in the block with these.

NOTE: Make a backup of your current file BEFORE you try this. I have not tried this code since I don't have the module loaded.


function rmmf_bk_comments($options){
    
$db =& Database::getInstance();
    
$myts =& MyTextSanitizer::getInstance();
    
$result $db->query("SELECT * FROM ".$db->prefix("rmmf_works")." ORDER BY id_w DESC");
    
$block = array();
    
$tmparray = array();
    while (
$row $db->fetchArray($result)){
        
$tmparray[] = $row;
    }
    
$limit = (count($tmparray) < $options[0]) ? count($tmparray) : $options[0] ;
    
$randarray array_rand($tmparray,$limit)
    for (
$i=0:$i<$limit:$i++) {
      
$rtn = array();
        
$rtn['id'] = $tmparray[$randarray[$i]]['id_w'];
        
$rtn['titulo'] = $tmparray[$randarray[$i]]['titulo'];
        
$rtn['texto'] = $myts->makeTareaData4Show($tmparray[$randarray[$i]]['comentario']);
        
$rtn['cliente'] = $tmparray[$randarray[$i]]['cliente'];
        
$block['works'][] = $rtn;
    }
    return 
$block;
}

function 
rmmf_bk_comments_edit($options){
    
$form _BK_RMMF_NUMCOMMS."<br /><input type='text' size='5' name='options[]' value='$options[0]' />";
    return 
$form;
}


Top

zyspec
Just can't stay away
Joined:
2004/9/21 9:28
Posts: 505
(Show More) (Show Less)
#3 Posted on: 2007/2/8 5:17 Re: Pull random quotes from RM Myfolder
Thx Zyspec! But when I try it I get a blank screen

Any other thoughts?

Top


. . . : : : | | | PressureLab.com | | | : : : . . .
bassyard
Not too shy to talk
Joined:
2003/10/5 7:30
From Antwerp, Belgium
Posts: 154
(Show More) (Show Less)
#4 Posted on: 2007/2/8 8:29 Re: Pull random quotes from RM Myfolder
2 things...

1st... My DUMB mistake - should have read through the code before I sent it!

Change line 12 of the code I posted from:
for ($i=0:$i<$limit:$i++) {


to:
for ($i=0;$i<$limit;$i++) {


Note you're changing the ':' (colon) to a ';' (semicolon)

2nd... Turn on PHP debug in Admin=>Preferences and report back with any errors.

Top

zyspec
Just can't stay away
Joined:
2004/9/21 9:28
Posts: 505
(Show More) (Show Less)
#5 Posted on: 2007/2/8 10:20 Re: Pull random quotes from RM Myfolder
I'm getting this error now:


Parse error
syntax errorunexpected T_FOR in cms/modules/rmmf/blocks/rmmf_recent.php on line 85
All errors 
(0queries (14blocks (4extra (0timers (4)
Errors


That's this line:


for ($i=0;$i<$limit;$i++) {


Thx for your time! Really appreciated!!

Top


. . . : : : | | | PressureLab.com | | | : : : . . .
bassyard
Not too shy to talk
Joined:
2003/10/5 7:30
From Antwerp, Belgium
Posts: 154
(Show More) (Show Less)
#6 Posted on: 2007/2/8 11:54 Re: Pull random quotes from RM Myfolder
Aaarrrgggghhhh - another DUMB mistake.

Please add a ';' to the end of line 84 - which should look like:


$randarray 
array_rand($tmparray,$limit)[b][color=FF0000];[/color][/b]


Top

zyspec
Just can't stay away
Joined:
2004/9/21 9:28
Posts: 505
(Show More) (Show Less)
#7 Posted on: 2007/2/8 14:19 Re: Pull random quotes from RM Myfolder
heheh now the block shows but without any content
and the follow error appears:


Notice
Undefined indexin file /modules/rmmf/blocks/rmmf_recent.php line 87
Notice
Undefined indexin file /modules/rmmf/blocks/rmmf_recent.php line 88
Notice
Undefined indexcliente in file /modules/rmmf/blocks/rmmf_recent.php line 90


If you can't find the problem: don't worry, I'll get a seperate quote module and enter the quotes there too so they appear in a block...

Top


. . . : : : | | | PressureLab.com | | | : : : . . .
bassyard
Not too shy to talk
Joined:
2003/10/5 7:30
From Antwerp, Belgium
Posts: 154
(Show More) (Show Less)
#8 Posted on: 2007/2/8 16:11 Re: Pull random quotes from RM Myfolder
Hmmmm....

If I get time in the next couple of days I'll load the module on a test server and see if I can get it working.

In the mean time maybe one of the PHP gurus here can see the problem in the code - it's probably something obvious that I've overlooked but without loading it and debugging it I just don't see it off the top of my head. That's why they don't let the same people that code a module test it!

You did set the number of quotes to show in the block configuration, right?

Top

zyspec
Just can't stay away
Joined:
2004/9/21 9:28
Posts: 505
(Show More) (Show Less)
#9 Posted on: 2007/2/9 2:48 Re: Pull random quotes from RM Myfolder
Quote:

zyspec wrote:
You did set the number of quotes to show in the block configuration, right?


I forgot to check this, it was set to display 1 quote, but when I changed it to 2 quotes, they show without errors, and at random!!
When I changed it back to 1 quote, the quote dissappears again, and the errors are back...

I hope this helps with a sollution, if not: I thank you VERY much for your effort! I can use it with 2 qoutes meanwhile, so it's all good!!

Top


. . . : : : | | | PressureLab.com | | | : : : . . .
bassyard
Not too shy to talk
Joined:
2003/10/5 7:30
From Antwerp, Belgium
Posts: 154
(Show More) (Show Less)
#10 Posted on: 2007/2/11 17:56 Re: Pull random quotes from RM Myfolder
bassyard,

I tried the code above (with the 2 sets of errors corrected) and the block displays random events correctly. I made one additional change in the code (although the original code worked fine) to remove sorting the customer comments in the SQL statement since they're randomized anyway and to only show Works with customer reviews in the block (eg. where customer review is not empty).

Please cut-and-paste the code below to replace your rmmf_bk_comments function and then let me know what happens.


function rmmf_bk_comments($options){
    
$db =& Database::getInstance();
    
$myts =& MyTextSanitizer::getInstance();
    
$result $db->query("SELECT * FROM ".$db->prefix("rmmf_works")." WHERE comentario != \"\"");
    
$block = array();
    
$tmparray = array();
    while (
$row $db->fetchArray($result)){
        
$tmparray[] = $row;
    }
    
$limit = (count($tmparray) < $options[0]) ? count($tmparray) : $options[0] ;
    
$randarray array_rand($tmparray,$limit);
    for (
$i=0;$i<$limit;$i++) {
      
$rtn = array();
        
$rtn['id'] = $tmparray[$randarray[$i]]['id_w'];
        
$rtn['titulo'] = $tmparray[$randarray[$i]]['titulo'];
        
$rtn['texto'] = $myts->makeTareaData4Show($tmparray[$randarray[$i]]['comentario']);
        
$rtn['cliente'] = $tmparray[$randarray[$i]]['cliente'];
        
$block['works'][] = $rtn;
    }
    return 
$block;
}


Note: This modified code will display all Customer comments if the "Number of Comments" (set in block preferences) is larger than the number of Works that actually contain customer comments.

Top

zyspec
Just can't stay away
Joined:
2004/9/21 9:28
Posts: 505
(Show More) (Show Less)

 Top   Previous Topic   Next Topic


You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]