https://www.icyphoenix.com/viewtopic.php?f=26&t=4407 ----------------------------------- whiskey_pete Wed 16 Jul, 2008 00:33 FAP CUSTOMIZATION - Integration Of JS Rating Widget ----------------------------------- I'm not really sure if I should post this here or in the IP customisations forum :| Anyway here's my problem: The users on my site have been complaining for quite long that the way of rating pics is too slow and complicated.I recently searched google and found this [url="http://js-kit.com/ratings/"]very decent widget which seems to be highly customisible and easy to use. So far so good :) , but in order to save the rating for every pic the widget needs a unique URL to refer to for every single pic from the album. On albun_showpage i used the {U_PIC_FULL_URL} function and it worked fine: http://worldbiology.net/album_showpage.php?pic_id=8&sid=7fea0c0c472fc3dc48fbd1a3b9f094bb this is the piece of code for the rating widget i used there: [code linenumbers=false] {L_RATING}:
[/code] Unforunately such function doesn't exist in album_cat.php and since my knowledge of php coding is very limited i was unable to reproduce it there :( Can someone please tell me what showld I do to get the same urls in both album_sowpage.php and album_cat.php? This is my testing site: http://worldbiology.net/test-cat-1-ac1.html I think that if working properly this widget will make a great customisation for FAPs rating systhem. Thank you in advance for any thoughts on this. ----------------------------------- Artie Wed 16 Jul, 2008 04:12 Re: Integration Of JS Rating Widget ----------------------------------- See if this will work for you [b]OPEN[/b] includes/album_mod/album_hierarchy_sql.php [b]FIND[/b] [codeblock]'PIC_ID' => $picrow[$j]['pic_id'],[/codeblock] [b]AFTER ADD[/b] [codeblock]'U_PIC_FULL_URL' => $server_path . ALBUM_UPLOAD_PATH . $picrow[$j]['pic_filename'],[/codeblock] [b]In album_cat_body.tpl use[/b] (anywhere between and ) [codeblock] {index_pics_block.picrow.pic_detail.U_PIC_FULL_URL} [/codeblock] ----------------------------------- whiskey_pete Wed 16 Jul, 2008 11:31 Re: Integration Of JS Rating Widget ----------------------------------- It works, but only on album_cat.tpl. The widget still cant make a refrance bettwen tne pic on album_showpage.tpl and the thumbnail on album_cat.tpl I made a test to see what is the output of the two functions by placing this code from anothwr thread: for {U_PIC_FULL_URL} [code linenumbers=false] [/code] output is [b]http://WorldBiology.net/files/album/d487cef125753f0852423f9a8ee25f65.png [/b] for {index_pics_block.picrow.pic_detail.U_PIC_FULL_URL} [code linenumbers=false] [/code] output is [b]files/album/d487cef125753f0852423f9a8ee25f65.png [/b] ----------------------------------- Artie Wed 16 Jul, 2008 23:20 Re: Integration Of JS Rating Widget ----------------------------------- I assume you need the absolute path ([b]http://WorldBiology.net/files/album/d487cef125753f0852423f9a8ee25f65.png[/b]) in both showpage and album_cat for all to work correctly? Adding the following code to what you have already added should give you that absolute path in album_cat... OPEN [b]album_heirarchy_sql.php[/b] FIND [codeblock]$template->assign_block_vars('index_pics_block.picrow.pic_detail', array([/codeblock] BEFORE ADD [codeblock]// server_path required for JS-Kit's Ratings widget $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; $server_name = trim($board_config['server_name']); $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; $script_name = preg_replace('/^/?(.*?)/?$/', '1', trim($board_config['script_path'])); $script_name = ( $script_name == '' ) ? '' : $script_name . '/'; $server_path = $server_protocol . $server_name . $server_port . $script_name;[/codeblock] ----------------------------------- whiskey_pete Mon 28 Jul, 2008 15:49 Re: Integration Of JS Rating Widget ----------------------------------- It Works! Thank you Artie :thanks: ----------------------------------- KugeLSichA Mon 04 Aug, 2008 17:10 Re: Integration Of JS Rating Widget ----------------------------------- [b]@whiskey_pete[/b] is this running nice? maybe are you willing to share this with us? thx. [b]@MG[/b] is it possible to integrate the rating block from topics to the album?? the functions is similar to the one which whiskey_pete uses... ----------------------------------- whiskey_pete Tue 05 Aug, 2008 00:09 Re: Integration Of JS Rating Widget ----------------------------------- Knowing what Artie told me it's really not hard to integrate the rating widget. [url=http://worldbiology.net/album.php]Demo site - may change with time Please note that I don't have much experience with html or php, so the code below [b]may contain errors[/b] (though its working fine on my test site). You are [b]highly advised to back up[/b] the files you edit when installing this widget! [b]OPEN[/b] includes/album_mod/album_hierarchy_sql.php [b]FIND[/b] [code linenumbers=false]'PIC_ID' => $picrow[$j]['pic_id'],[/code] [b]AFTER ADD[/b] [code linenumbers=false]'U_PIC_FULL_URL' => $server_path . ALBUM_UPLOAD_PATH . $picrow[$j]['pic_filename'],[/code] [b]FIND[/b] [code linenumbers=false]$template->assign_block_vars('index_pics_block.picrow.pic_detail', array([/code] [b]BEFORE ADD[/b] [code linenumbers=false]// server_path required for JS-Kit's Ratings widget $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; $server_name = trim($board_config['server_name']); $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; $script_name = preg_replace('/^/?(.*?)/?$/', '1', trim($board_config['script_path'])); $script_name = ( $script_name == '' ) ? '' : $script_name . '/'; $server_path = $server_protocol . $server_name . $server_port . $script_name;[/code] [b]OPEN[/b] templates/mg_themes/album_showpage_body.tpl [b]FIND[/b] [code linenumbers=false] {L_RATING}: {PIC_RATING}
 

[/code] [b]REPLACE WITH[/b] [code linenumbers=false] {L_RATING}:
[/code] [b]OPEN[/b] templates/mg_themes/album_cat_body.tpl [b]FIND[/b] [code linenumbers=false] {index_pics_block.picrow.pic_detail.RATING} [/code] [b]REPLACE WITH[/b] [code linenumbers=false]
[/code] For customisations like how to change the default stars with your own images please see here: http://js-kit.com/ratings/custom.html To increase reliability of the widget you can upload te ratings.js in to you root directory (I'm not very sure though if this is not a copyright violation) You can suposedly also edit the .js file itself to localize it for your forum language. Just open the file in a text edittor and translate the variables you need in your language. ----------------------------------- Mighty Gorgon Tue 05 Aug, 2008 02:25 Re: Integration Of JS Rating Widget ----------------------------------- First of all thank you very much [b]@whiskey_pete[/b] for your great "How To". :mri: [quote user="KugeLSichA" post="30288"][b]@MG[/b] is it possible to integrate the rating block from topics to the album?? the functions is similar to the one which whiskey_pete uses...[/quote][b]whiskey_pete[/b], Yes it is possible... but currently I am working on other things... :roll: I have personally coded the rating in viewtopic... so the code is free and it is there ready to be used... it needs just someone with a bit of free time to implement it. It shouldn't be difficult... anyone?