What version of 68 Classifieds are you running? v4.2.1 Developer Sigma Ocean Please describe in detail the issue you are having: First of all a good 2011 and happy new year. I have added an extra field with checkbox to allow the registered advertiser to turn on or off the rating module. I found the below function in the forum which I think is usefull. Code: <?php function smarty_function_mycheckbox($params, &$smarty) { global $db,$modules; $id = ''; $fid = ''; foreach ($params as $_key=>$_value) { switch ($_key) { case 'id': case 'fid': $$_key = (int)$_value; break; } } if($fid >0) { $sSQL = "SELECT fName FROM ".PREFIX."fields WHERE fID='".$fid."'"; $result=$db->query($sSQL); if($result->isError()) { return false; } if($result->size()>0) { $rs=$result->fetch(); } } if($id > 0) { $sSQL = "SELECT sValue FROM ".PREFIX."products_fields WHERE pID='".$id."' AND fID=".$fid; $result=$db->query($sSQL); if($result->isError()) { return false; } if($result->size()>0) { $rs=$result->fetch(); $rs['sValue']=str_replace(" | ", ", ", $rs['sValue']); $check=str_replace("|", "", $rs['sValue']); } } if($check != NULL) { ?> <img src="http://www.yourdomain.com/photos/paypal.jpg"> <?php } } Instead of <img src="http://www.yourdomain.com/photos/paypal.jpg"> I use.... Code: if($check != NULL) { ?> {assign var="rating" value=$smarty.const.FILESYSTEM_PATH} {include file="$rating/modules/rating/templates/listing_rating.tpl"} <?php } } Unfortunaytely this seems not to work? With a picture or just text the function works mighty fine! If I change the code to... Code: if($check != NULL) { $ratemylisting="Y"; echo $ratemylisting; } } and in viewlisting.tpl to.. Code: {mycheckbox id=$view fid=3} {if $ratemylisting=="Y"} {dynamic} {assign var="rating" value=$smarty.const.FILESYSTEM_PATH}<br/>{include file="$rating/modules/rating/templates/listing_rating.tpl"} {/dynamic} {/if} then this also don't work (it echo the Y correctly!) Who can give me some direction. What do I overlook? Thank you in advance.
I didnt look to closely but the following sticks out.. {assign var="rating" value=$smarty.const.FILESYSTEM_PATH}<br/>{include file="$rating/modules/rating/templates/listing_rating.tpl"} its assigning a value of "rating" to the variable $rating and using it in the path so the path is... rating/modules/rating/templates/listing_rating.tpl I think if you look thats not a valid path to the template needed.
Larry, I thought also a path issue, but I have tried everything already related to the path's. I assume it is something with the function or the smarty part What I want to do is to give the user the oppurtunity to turn on or off the rating module, see the Rating mod rating-v1.7.1.zip - elbmods - Rating v1.7.1 - Project Hosting on Google Code but no joy yet...
In viewlisting.tpl I have added Code: {capture name='foo'} {myratingcheckbox id=$view fid=3} {/capture} {$smarty.capture.foo} {if $smarty.capture.foo=="YES"} {include file="http://www.kidsspullen.nl/modules/rating/templates/listing_rating.tpl"} {/if} and in the function file Code: if($check != NULL) { $output ="YES"; return $output; } } It shows nice YES on my site but not the rating mod....
Ok. after a lot of trial and error I have.. Code: {capture name=foo} {mycheckbox id=$view fid=3} {/capture} {$smarty.capture.foo} {if $smarty.capture.foo=="N"} text A {elseif $smarty.capture.foo=="Y"} text B {/if} Depends on the checkbox checked or not it display the {$smarty.capture.foo} Y if checked and N if not checked. Unfortunately I don't see why te below part don't work...It drives me Code: {if $smarty.capture.foo=="N"} text A {elseif $smarty.capture.foo=="Y"} text B {/if} Who can help me with this? Thank you in advance.
Im having a hard time understanding the above quoted content. Your saying the upper bit of smarty works but the bottom doesnt? Are you replaceing the whole top bit of code with the bottom bit of code in the same template?
Larry, Sorry I was not clear This works Code: {capture name=foo} {mycheckbox id=$view fid=3} {/capture} {$smarty.capture.foo} it output a Y or a N And after above mentioned I have Code: {if $smarty.capture.foo=="N"} text A {elseif $smarty.capture.foo=="Y"} Text B {/if} And in this part something is wrong .. at least I think. I does not show Text A nor Text B
if the checkbox of the extrafield is checked it give as output Y and if the checkbox of the extrafield is not checked it give as output N so far so good. But if I want to use this output in the {if $smarty.capture.foo=="N"} text A {elseif $smarty.capture.foo=="Y"} text B {/if} then it don't work and no text A (n)or text B appear.
I'm getting quite confused with what you are saying and your posted code. Bear in mind that Smarty is not "AJAX" javascript. Personally, I think you're overcomplicating this quite a bit and going about it in an the incorrect way. Unless I'm misunderstanding your goal. You are wanting to either show output or not show output from a module, based on an extra field that you have elsewhere (in the actual template???). If it were me and you wanted to offer this as an option on a per listing basis, then you should set up a standard extra field and assign it to each category that you want to offer the option to. Set it to NOT display in the listing. Then modify the actual module that you either want to display the output of or not. In the function that would display this in the template, precede it with and if statement that checks what the value of the extra field is. If it's set to "N" return FALSE, else run the rest of the existing code.
Hello Mike, Maybe I overcomplicating things....but I'm not sure anymore. But what I have done is the following. A user who make a listing can thick a checkbox (Which I as adminstrator have added in the extrafields)to activate the rating mod for that listing. I found in the forum function.mycheckbox.php from seymourjames, http://www.68classifieds.com/forums/technical-support/8797-assigning-variables-2.html#post45156 I modified it so that it output a Y ( from Yes) if the user allow to rating of its listing. (so he has ticked the checkbox) and it output a N (from No) if the user don't allow to rating of it's listing. (so he has not ticked the checkbox) then in viewlisting.tpl I capture this value with {capture name=foo} {mycheckbox id=$view fid=3} {/capture} {$smarty.capture.foo} and then throw it in a If statement. {if $smarty.capture.foo=="N"} text A {elseif $smarty.capture.foo=="Y"} text B {/if} For testing purpose I use text A and text B just to see if it will output these text on the website I think I'm on the right track, but I overlook something. (sorry for my bad English which can cause some confusion)
The plugin for the checkbox is not going to do this for you. A smarty plugin is designed to run whatever logic/code you have in it and then return/display a result. The result is displayed when the page is rendered. Once the page is rendered it is NOT going to then go back and get the output of a module which is what you are asking it to do (That was what my reference of it is NOT "AJAX" or javascript meant). So, if you re-read my previous post and get rid of the smarty checkbox plugin and follow my post it will work. You seem to have all of the right kind of logic, you just have it in the wrong places (eg in the template and smarty plugins). The seller than checks or not whether they want to display the rating or not when they place the ad or edit the ad. The module checks that field first and then either displays the rating template or it doesn't based on the extra field BEFORE the page is rendered. It really is that simple.
Ok little lost now... I have set up a standard extra field (order 3, id 3, fieldname rating, fieldtype checkboxes) and I assign it to each category that I want to offer the option to. I put it to NOT display in the listing. This is the easy part. I have some trouble to understand this: " Then modify the actual module that you either want to display the output of or not. In the function that would display this in the template, precede it with and if statement that checks what the value of the extra field is. If it's set to "N" return FALSE, else run the rest of the existing code. " Do you mean something like below in the viewlisting.tpl...? {capture name=test assign=myvar} {get_extra_field id=$view fid=3} {/capture} {if $myvar == 'test'} {$myvar} rating mod {else} no rating allowed {/if} or something like.... {if $extrafields.3.title == rating && $extrafields.3.value == False} Showrating mod {else} no rating allowed {/if}
NO! Not at all, what I'm saying is get rid of ALL of that stuff in the template file except for anything that the ratings module requires (if it requires anything in the template). Then you need to modify the function that is in the RATINGS MODULE that displays the ratings. Put your database query to check for the extra field in the function before everything that is currently in there now. Then make an if statement based off of the database query you just did. If the value is "N" return FALSE (eg nothing), ELSE run the rest of the function the way that it is so that it will display the ratings. If you still don't understand what I'm saying, my best advice would be to hire someone to do it for you, like me or any of the other "Professionals" listed in the Classifiedmods.com site.
Sometimes you have to give it a try later...so I did with the help of the previous posts I modified the function smarty_function_mycheckbox($params, &$smarty) to my needs and inserted at the end if($check != NULL) { $smarty->display(FILESYSTEM_PATH .'/modules/rating/templates/listing_rating.tpl'); } In viewlisting.tpl I added at the place I want {mycheckbox id=$view fid=3} Furthermore I modified the listing_rating.tpl to my needs and now it worked finally..