Advertisement:

Author Topic: [Solved] explode custom fields on item.php  (Read 38910 times)

Silent Reader

  • Jr. Member
  • **
  • Posts: 54
Re: [Solved] explode custom fields on item.php
« Reply #15 on: January 03, 2014, 04:17:59 pm »
Hello again,
Just a few minutes modifying that code and I find something more cool  ;D

From that array, we can change all that to this

Code: [Select]
<?php $custom_field = array();
            if( 
osc_count_item_meta() >= ) { 
                    while ( 
osc_has_item_meta() ) { 
                        if(
osc_item_meta_value() !="") {
            
$custom_field_name[osc_item_meta_slug()] = osc_item_meta_name();
            
$custom_field_value[osc_item_meta_slug()] = osc_item_meta_value();
                        }
                    }
?>


So, applying that to item page is something like this
#example you have field with name "Your Address", an identifier name "user-address-private"

the it should be

Code: [Select]
<p class="left"><?php echo $custom_field_name['user-address-private'] ;?>: <strong><?php echo $custom_field_value['user-address-private'] ;?></strong></p>

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [Solved] explode custom fields on item.php
« Reply #16 on: January 03, 2014, 06:41:17 pm »
very good…more then one way to skin a cat!!
I guess that is why scripts get updated so often, someone turns up with something different.

Silent Reader

  • Jr. Member
  • **
  • Posts: 54
Re: [Solved] explode custom fields on item.php
« Reply #17 on: January 04, 2014, 01:12:03 am »
Thank you very much for this useful code.It works like a charm. ;D Can you please tell me how to move each custom field in item-post.php?Ex:Custom1 after price,Custom2 after Region and so on.
Thank you!

I've work about two days to findout a function or script to do that on item-post.php but nothing!
The id and name of that input was generate randomly with number. If you see that code in running page using chrome Inspect element (etc), you'll see an id such "dp1263524465" or meta[14] etc

# thought if there's a define for that

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [Solved] explode custom fields on item.php
« Reply #18 on: January 04, 2014, 01:45:32 am »
i'm not sure what you are asking?

Silent Reader

  • Jr. Member
  • **
  • Posts: 54
Re: [Solved] explode custom fields on item.php
« Reply #19 on: January 04, 2014, 08:45:59 am »
i'm not sure what you are asking?

That guy ask on how to modify the display form input of each custom field on item-post.php or item-edit.php rather than automatically display them with <?php ItemForm::plugin_post_item(); ?>. I say that at least we have the define function to get each custom field input "name and id", I think we can find way.  :D

killday

  • Jr. Member
  • **
  • Posts: 74
Re: [Solved] explode custom fields on item.php
« Reply #20 on: February 24, 2014, 10:15:44 am »
Hi all,

I see a lot of good work here. My ask is if anyone has some development on the scripts here, please share. I'm working on translating Custom Fields and the code here will help me a lot.

Regards
Killday

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [Solved] explode custom fields on item.php
« Reply #21 on: February 24, 2014, 09:36:44 pm »
there is no need for development because this is a personalization. I suppose you need to work out what it is you want. ...
what do you want it to do? because out of the box it is looped, but this code pulls out each field separately so it can be styled any way that fits your theme.
that was the point of this thread.
and as there is more then one way to do things, there is more then one option to accomplish this, in this thread.

and as I look back I still don't understand dao LOL

Emmanuel

  • Hero Member
  • *****
  • Posts: 645
  • .: ♥ Quality Swiss Details ♥ :. .: Swiss Made :.
Re: [Solved] explode custom fields on item.php
« Reply #22 on: March 26, 2014, 01:17:24 am »
Hi all,

Well, Widgets made easy  ;)

https://github.com/osclass/Osclass/pull/1428

Have a great day
Emmanuel

strata

  • Sr. Member
  • ****
  • Posts: 411
  • Always good, always...
Re: [Solved] explode custom fields on item.php
« Reply #23 on: March 28, 2014, 04:59:21 am »
I want to explode the custom field on premium listing but helper for this not ready:
- osc_premium_meta_name()
- osc_premium_meta_field()
and custom meta field on search-sidebar it's not showing the default option like on item-post for the dropdown, like on on picture attached.
any advice and help would be great  ;D


aide2001

  • Guest
Re: [Solved] explode custom fields on item.php
« Reply #24 on: March 28, 2014, 01:28:38 pm »
This works great, thanks

DJNiko

  • Jr. Member
  • **
  • Posts: 51
Re: [Solved] explode custom fields on item.php
« Reply #25 on: April 17, 2014, 05:33:28 pm »
For Premium

Code: [Select]
<?php 

osc_get_premium_meta();
$custom_fields = array();
           if( 
osc_count_premium_meta() >= ) { 
                   while ( 
osc_has_premium_meta() ) { 
                       if(
osc_item_meta_value() !="") {
           
$custom_fields[osc_item_meta_name()] = osc_item_meta_value();
                       }
                   }
              } 
             
              
              
?>


obida

  • Newbie
  • *
  • Posts: 42
Re: [Solved] explode custom fields on item.php
« Reply #26 on: April 22, 2014, 11:40:25 am »
Hi Guys,

Thats sounds great solution , but its not working with me :(

I have a custom field with name custom_city as shown in the attached image .

And implemented the code same as you mentioned :
Code: [Select]
<?php $custom_field = array();
                         if( 
osc_count_item_meta() >= ) { 
                            while ( 
osc_has_item_meta() ) 
                            { 
                                if(
osc_item_meta_value() !=""
                                {
                                    
$custom_field_name[osc_item_meta_slug()] = osc_item_meta_name();
                                    
$custom_field_value[osc_item_meta_slug()] = osc_item_meta_value();
                                }
                            }
                       }                       
?>

                        <div><?php echo $custom_field_name['custom_city'] ;?>: <strong><?php echo $custom_field_value['custom_city'] ;?></div>


I don't know why when im printing <?php echo "Number of custom fields" . osc_count_item_meta() ; ?> it gives me 0 !!!
 
Why its happening with me ?!?

Thanks,
« Last Edit: April 22, 2014, 11:57:19 am by obida »

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [Solved] explode custom fields on item.php
« Reply #27 on: April 22, 2014, 06:12:38 pm »
try using the original code then, earlier on in the thread

obida

  • Newbie
  • *
  • Posts: 42
Re: [Solved] explode custom fields on item.php
« Reply #28 on: April 22, 2014, 06:17:48 pm »
Thank you @design for your prompt action .

Sure i used @teseo code , as following :

Code: [Select]
<?php $custom_fields = array();

                                if( 
osc_count_item_meta() >= ) { 

                                        while ( 
osc_has_item_meta() ) { 
                                            if(
osc_item_meta_value()!='') {

                                        
$custom_fields[osc_item_meta_name()] = osc_item_meta_value();
                                         
// Residue: echo osc_item_meta_name(); echo osc_item_meta_value();

                                        
}
                                    }
                                 } 
?>


                            <div><strong>Custom_field1: </strong><?php echo $custom_fields['custom_city'] ;?></div>

"custom_city" is the Identifier name of the custom field .

But i get the following error :

Notice: Undefined index: custom_city in XXXXXX/main.php on line 288

Dunno what to do !!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [Solved] explode custom fields on item.php
« Reply #29 on: April 22, 2014, 06:51:12 pm »
Hi,

Is it "custom_city" enabled for all categories? ???

If so and it must appear there, insert provisionally this line before that div:

Code: [Select]
<?php var_dump($custom_fields); ?>
And copy the printed array here.

Regards