Osclass forums

Support forums => old => Topic started by: tinkerton on June 14, 2015, 11:26:51 pm

Title: [SOLVED] How to add custom fields to Grid Listings?
Post by: tinkerton on June 14, 2015, 11:26:51 pm
I want content from custom fields to be displayed under the pictures in Grid Listing Format. I've read that custom fields need to be separated but I can't seem to make it work. I found out that I could change the content below the picture in my main page by editing this code in /themes/osclasswizards/loop-grid.php.

(http://i61.tinypic.com/25qahrr.png)

Code: [Select]
<article> <span class="category"><i class="fa fa-map-marker"></i> <?php echo osc_item_category() ; ?></span> <span class="location"> <i class="fa fa-map-marker"></i> <?php echo osc_item_city(); ?>
        <?php if( osc_item_region()!='' ) { ?>
        (<?php echo osc_item_region(); ?>)
        <?php ?>
        </span> <span class="date"> <i class="fa fa-clock-o"></i> <?php echo osc_format_date(osc_item_pub_date()); ?> </span> </article>

Also, I'm having trouble changing the content displayed in the Category Pages. Which file is responsible for the grid listing in category pages?

Theme: OsclassWizards 2.0.0 by OsclassWizards
Osclass 3.5.7
Title: Re: How to add custom fields to Grid Listings?
Post by: SmaRTeY on June 19, 2015, 09:36:34 pm
Hi,

after a quick search I found this thread, see if it can help you:
http://forums.osclass.org/bender/explode-custom-fields-on-item-php/ (http://forums.osclass.org/bender/explode-custom-fields-on-item-php/)


Regards,
Eric
Title: Re: How to add custom fields to Grid Listings?
Post by: teseo on June 20, 2015, 12:37:39 am
Hi,

I think this most recent solution is better:

http://forums.osclass.org/themes/problem-on-the-call-two-time-meta-field/msg106769/#msg106769 (http://forums.osclass.org/themes/problem-on-the-call-two-time-meta-field/msg106769/#msg106769)

Regards
Title: Re: How to add custom fields to Grid Listings?
Post by: Osclass Wizards on June 20, 2015, 12:44:58 pm
For any kind of theme related bugs you can report here

http://forums.osclass.org/themes/osclasswizards-free-responsive-bootstrap-theme/ (http://forums.osclass.org/themes/osclasswizards-free-responsive-bootstrap-theme/)
Title: Re: How to add custom fields to Grid Listings?
Post by: tinkerton on June 21, 2015, 05:05:55 am
Thanks! I finally got it to work. :)
Title: Re: How to add custom fields to Grid Listings?
Post by: SmaRTeY on June 21, 2015, 02:36:38 pm
Great tinkerton,

please help others with your fix / solution by telling us what you exactly did and what the result is.
Also we'd like to ask you to put SOLVED inthe subject of this thread so others can see this question also has a solution.


Thanks,
Eric
Title: Re: How to add custom fields to Grid Listings?
Post by: tinkerton on June 27, 2015, 08:04:21 pm
Step 1:

Add this at the very bottom of your theme functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_get_custom_field_value($name) {

    
$getItemMeta osc_get_item_meta();
    
$name '/^'$name '$/';
    
$index array_filter($getItemMeta, function($a) use($name)  {
        return 
preg_grep($name$a);
    });

    return 
$getItemMeta[key($index)]['s_value'];

?>

Step 2:

Now in loop-grid.php and loop-search-grid.php put this where you want your custom field. Custom field name = customfield1

Code: [Select]
<?php echo cust_get_custom_field_value(customfield1); ?>
Thanks!
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: Zacdaniel on June 29, 2015, 08:25:18 pm
Something I will be using

Thanks
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: polaris_ua on December 30, 2015, 12:14:48 am
Hi guys! First appreciate for sharing your solutions! Great work! Wondering if it's possible to use this with custom attr plugins like cars attributes. Need some custom fields from cars attributes put in loop-search-grid.php. Tried this but not working for me on osclasswizards theme
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: expertdeveloper on January 03, 2016, 01:27:30 am
yes you can do that if you have a little php knowledge.
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: p206ab on March 03, 2018, 01:50:59 pm
Any ideas how to use this with Multilanguage Custom Fields?
It works and the field names gets translated, but the values don't.
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: teseo on March 03, 2018, 02:01:38 pm
Hi,

The plugin includes a special function to do just that: mlcf_get_translated_custom_field('identifier'), see Help page.

Regards
Title: Re: [SOLVED] How to add custom fields to Grid Listings?
Post by: p206ab on March 03, 2018, 03:28:06 pm
Hi,

The plugin includes a special function to do just that: mlcf_get_translated_custom_field('identifier'), see Help page.

Regards
Oh, didn't notice that before, thanks.  ;)