Support Forums


Go Back   68 Classifieds Forums > Legacy Help & Support > v3.1 Modules & Modifications

 
LinkBack Thread Tools Display Modes
Old 03-03-2007, 12:13 PM   #1
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default listing extra field value when it is an array?

I'm hoping someone might be able to give me a solution for this dilemma.

This is in relation to a previous thread:
Different template for categories?

Thanks given to juven14, Lhotch and especially suzkaw for help with getting my custom templates to work for different categories. Currently, all of my extra fields look great in the custom template, except that the features is currently empty, because the value simply returns "array"
Nice fake truck listing

My current dilemma is that i can not get the extra field for the features to display in my vehicle template. the issue is that the call to the extra field value is an array (This is because the field is a checkbox field).
Snippet from the "debug" capture to display the template with the extra fields. The "Features" field is 10 in the capture of data.
PHP Code:
10 => Array (3)
  
fID => 6
  title 
=> Features
  value 
=> Array (17)
    
=> 4 Door
    1 
=> Air Bags
...
    
15 => Tilt Wheel
    16 
=> empty 
So when I put in my template $extra.10.value, it returns the word, "array"
I tried stealing the code from the viewlistings.tpl.php file to attempt to extract it that way:
PHP Code:
{if isset($extras.value)}
    {foreach 
key=key item=item from=$extras.value}
    {
$item}<br />
    {/foreach}
{/if} 
That didn't work. I also tried "from=$extra.10.value" that didn't work. I tried "isset($extras.10.value) which also didn't work.

Any smart php/smarty guru have a suggestion to make this work?

Ultimately, I would like to have the array display as
$item, $item, $item, until the end of the selected features.

Thanks in advance for any help.

Sincerely,
-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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 03-03-2007, 12:50 PM   #2
Moderator
 
 
Join Date: Mar 2006
Posts: 4,224
Rep Power: 103
Lhotch is just really niceLhotch is just really nice
Default

What your dealing with is actually a multidimensional array or more simply put, a variable that has multiple values and some of those values are actually arrays themselves.


Try something like the following...

{foreach name=outer item=extra from=$extras.value}
<hr />
{foreach key=key item=item from=$extra}
{$key}: {$item}<br />
{/foreach}
{/foreach}
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 03-03-2007, 05:15 PM   #3
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

Quote:
Originally Posted by Lhotch View Post
What your dealing with is actually a multidimensional array or more simply put, a variable that has multiple values and some of those values are actually arrays themselves.


Try something like the following...

{foreach name=outer item=extra from=$extras.value}
<hr />
{foreach key=key item=item from=$extra}
{$key}: {$item}<br />
{/foreach}
{/foreach}
Lhotch,

Thanks for the suggestion, but still no go. It is still blank under the features. This is the actual code that I put in my template to attempt to display the "Features" extra field.
PHP Code:
<tr>
    <
td align="left" valign="top" colspan=5>
    <!-- 
Features -->
    <
strong>{$extra.10.title}:</strong><br>&nbsp;
        {foreach 
name=outer item=extra from=$extras.value}
            {foreach 
key=key item=item from=$extra}
            {
$key}: {$item},&nbsp;
            {/foreach}
        {/foreach}
    </
td>
</
tr
-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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 03-05-2007, 06:29 PM   #4
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

OK, Now you've done it! You've made me have to resort to this...


Anyone, offer any more help with this????

-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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 03-06-2007, 12:17 PM   #5
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,844
Rep Power: 111
Eric Barnes is a jewel in the rough
Default

Try this although I am not sure if it will work either:

Code:
{foreach from=$extra item=extras}
{if $extras.id == 10}
            <tr>
                <td><strong>{$extras.title}:</strong></td>
                <td>
                    {if isset($extras.value)}
                      {foreach key=key item=item from=$extras.value}
                        {$item}<br />
                      {/foreach}
                     {/if}
                </td>
            </tr>
{/if}
            {/foreach}
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 03-06-2007, 05:58 PM   #6
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default



Still no go. This suggestion doesn't even show the title. Argh!

Thanks for trying though.

-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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 03-07-2007, 12:32 AM   #7
Senior Member
 
bgordon's Avatar
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 168
Rep Power: 15
bgordon is on a distinguished road
Question

I am having a similar problem where I want to show a small graphic beside each item from the fID 20 in my extras table. I don't want the little graphic beside each of the other items.

Included Options: (fID 20 in SQL table)[*]Option 1[*] Option 2 etc... etc....

I need some kind of "if" logic to show the graphic in the loop only if the item's fID==20.

Now, this being said, I think most people who use 68c add their own custom fields (since the power to do so is well designed into 68c). It seems to me that in adding our own fields, 68c should simply allow uses to call and place these items anywhere in their designs using CSS, tables or whatever. This whole idea of multidimensional arrays to store this data makes it hard for a nice design other than vomiting out the whole list line after line on a page.

Would this really be hard to change in 68.. maybe in the next release?

I understand that the extras can only be called within the scope of the category, but a change to the schema to allow us to make fields, populate them and recall them into our layouts on a field-by-field basis seems to be an oversight... one of the very few I must ad.

Something like $extra.category_id.extra_id would be perfect. This name would be created as each extra is created and could then be placed anywhere on the viewlistings or showlistings on a field-by-field basis. Where the field became an array with many selections then we would use the loop to show them. Where the field simply contained a single value or text string we could simply place it.

Any ideas or thoughts?
__________________
B. Gordon
v.4.0.9 Developer
bgordon is offline   Reply With Quote
Old 03-07-2007, 02:01 PM   #8
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Thumbs up Success!!!!

I finally got it to work! WooHoo!!!

Here's the code that worked the magic!
PHP Code:
{foreach key=10 item=item from=extras}
      {foreach 
key=key item=item from=$extra.10.value}
    {
$item}<br>
    {/foreach}
{/foreach} 
-Mike
__________________
Mike-N-Tosh
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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 03-07-2007, 02:10 PM   #9
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,844
Rep Power: 111
Eric Barnes is a jewel in the rough
Default

Glad you got it Mike.

Now to follow up with bgordon:
Quote:
Now, this being said, I think most people who use 68c add their own custom fields (since the power to do so is well designed into 68c). It seems to me that in adding our own fields, 68c should simply allow uses to call and place these items anywhere in their designs using CSS, tables or whatever. This whole idea of multidimensional arrays to store this data makes it hard for a nice design other than vomiting out the whole list line after line on a page.

Would this really be hard to change in 68.. maybe in the next release?
The extra fields are very complex and pulling them out as an array is the best way because it only requires one or two query's where going a different route may be very resource intensive. Of course I am not going to say the current way is the best or the most easy but it works and gets the data out.

Maybe when things slow down we can revisit this section and see how difficult it would be to pull them out differently but for right now it will stay the way it is.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-15-2007, 10:00 PM   #10
Senior Member
 
bgordon's Avatar
 
Join Date: Aug 2006
Location: Georgian Bay, Ontario Canada
Posts: 168
Rep Power: 15
bgordon is on a distinguished road
Question

Ok... I get the array challeng but seem unable to pull the individual values out...

I want to make my own table and be able to show the extras on a cell-by-cell basis where I want. I have fID numbers for all the common extras and am just missing how to call them for individual display.

Can you make me a little loop that I can use to call the value from an extra text field value based on the fID? I would then change this and re-use it wherever I wanted to display all my extra information in my new layout.

Also, would this little loop need to be modified to show the extras value from a field where the user chose a value from a list? or would the solution be the same with the relevant fID.

Thanks... this has been driving me nuts... I can't quite get this to work.

BTW: This loop would get used in showlistings and viewlisting templates where I want to make a snazzy layout that shows the extras in a formatted way as opposed to line-after-line.
bgordon is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
extra fields in the listing modification Acpjax v3.1 Questions & Support 4 11-20-2006 01:20 PM
Enabled extra field and pdf file keeps "falling out" of previous listings sedonagate v3.1 Questions & Support 3 09-21-2006 08:50 PM
Adding an Extra Field that is clickable sporthorsebreeder HTML, CSS, and Design Help 12 09-04-2006 02:03 AM
Displaying extra field in Search and category listings Bucketman v3.0 Questions & Support 3 04-26-2006 09:48 AM


All times are GMT -4. The time now is 02:25 PM.


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