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; What version of 68 Classifieds are you running? v4.2.1 Developer Sigma Ocean Please describe in detail the issue you are ...


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

Reply
 
Thread Tools Display Modes
Old 01-01-2011, 01:47 PM   #1
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default Extra field, check box

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.

Last edited by zooi; 01-02-2011 at 01:23 PM.
zooi is offline   Reply With Quote
Old 01-02-2011, 12:33 PM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,352
Rep Power: 134
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

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

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-02-2011, 02:18 PM   #3
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default

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...
zooi is offline   Reply With Quote
Old 01-02-2011, 03:38 PM   #4
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default

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....
zooi is offline   Reply With Quote
Old 01-03-2011, 07:35 AM   #5
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default

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.
zooi is offline   Reply With Quote
Old 01-03-2011, 10:16 AM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,352
Rep Power: 134
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by zooi
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

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-03-2011, 10:28 AM   #7
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default

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
zooi is offline   Reply With Quote
Old 01-03-2011, 10:30 AM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,352
Rep Power: 134
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

{$smarty.capture.foo} should be giving you some output, what does it show?
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 01-03-2011, 11:10 AM   #9
Customer
 
Join Date: Oct 2010
Posts: 49
Rep Power: 2
zooi is on a distinguished road
Default

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.

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

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.
__________________
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
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 02:58 AM.


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