Advertisement:

Author Topic: [SOLVED] How to add custom fields to Grid Listings?  (Read 3690 times)

tinkerton

  • Newbie
  • *
  • Posts: 4
[SOLVED] How to add custom fields to Grid Listings?
« 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.



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
« Last Edit: June 27, 2015, 08:05:22 pm by tinkerton »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: How to add custom fields to Grid Listings?
« Reply #1 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/


Regards,
Eric

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: How to add custom fields to Grid Listings?
« Reply #2 on: June 20, 2015, 12:37:39 am »

Osclass Wizards

  • Sr. Member
  • ****
  • Posts: 254
  • We love Osclass
Re: How to add custom fields to Grid Listings?
« Reply #3 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/

tinkerton

  • Newbie
  • *
  • Posts: 4
Re: How to add custom fields to Grid Listings?
« Reply #4 on: June 21, 2015, 05:05:55 am »
Thanks! I finally got it to work. :)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: How to add custom fields to Grid Listings?
« Reply #5 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

tinkerton

  • Newbie
  • *
  • Posts: 4
Re: How to add custom fields to Grid Listings?
« Reply #6 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!

Zacdaniel

  • Full Member
  • ***
  • Posts: 115
  • Why, Yes I'm a white african haha...
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #7 on: June 29, 2015, 08:25:18 pm »
Something I will be using

Thanks

polaris_ua

  • Newbie
  • *
  • Posts: 1
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #8 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

expertdeveloper

  • Newbie
  • *
  • Posts: 6
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #9 on: January 03, 2016, 01:27:30 am »
yes you can do that if you have a little php knowledge.

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #10 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.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #11 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

p206ab

  • Sr. Member
  • ****
  • Posts: 343
Re: [SOLVED] How to add custom fields to Grid Listings?
« Reply #12 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.  ;)