Support Forums

Extra field, check box

This is a discussion on Extra field, check box within the Technical Support forums, part of the Technical Support Forums category; Hello Mike, Maybe I overcomplicating things....but I'm not sure anymore. But what I have done is the following. A user ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

Reply
 
Thread Tools Display Modes
Old 01-03-2011, 04:53 PM   #11
Customer
 
Join Date: Oct 2010
Posts: 52
Rep Power: 3
zooi is on a distinguished road
Default

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, assigning variables

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)

Last edited by zooi; 01-03-2011 at 04:57 PM.
zooi is offline   Reply With Quote
Old 01-03-2011, 05:20 PM   #12
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,120
Rep Power: 63
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

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.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2,5.0)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline   Reply With Quote
Old 01-04-2011, 04:19 PM   #13
Customer
 
Join Date: Oct 2010
Posts: 52
Rep Power: 3
zooi is on a distinguished road
Default

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}

Last edited by zooi; 01-04-2011 at 04:42 PM.
zooi is offline   Reply With Quote
Old 01-04-2011, 04:59 PM   #14
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,120
Rep Power: 63
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

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.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2,5.0)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out

Last edited by Mike-N-Tosh; 01-04-2011 at 05:03 PM.
Mike-N-Tosh is offline   Reply With Quote
Old 01-09-2011, 08:59 AM   #15
Customer
 
Join Date: Oct 2010
Posts: 52
Rep Power: 3
zooi is on a distinguished road
Default

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..
zooi is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra Fields Check Boxes Validation at User End leonardi Technical Support 4 04-29-2010 08:41 AM
Extra Field Search / Save Extra Field to Short Desciption tlombard Technical Support 8 03-04-2010 06:18 PM
V4.1.x Check all categories on adding extra field damiun Modules / Plugins / Modifications 2 08-09-2009 08:21 AM
Check Box Extra Field Layout ... MrGForce Technical Support 10 07-20-2009 11:00 PM


All times are GMT -4. The time now is 04:32 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0