May 4, 2011

Array and Custom Fields. | CyberSEO Pro | Support Forum

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_TopicIcon
Array and Custom Fields.
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
May 25, 2018
4:16 am
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline

Hi. it’s hard to get help by email so I write here. can anyone know the solution known?

How to save these variables to a custom field.

Login to see the quote

I don’t have a problem to save this array to tags of post.

I do. 

Login to see the quote

and by custom php code cyberseo plugin add this array to the tags. but i don’t know why is don’t save it to the custom field – is always empty. 

Login to see the quote

I would like to get a custom field with will be listed 

language by decimal like i get when I get tags added to post. 

 

maybe is a code the reverse job. and save the tags generated at the beginning with the post again to the custom field?

tnx for help. 

May 25, 2018
4:49 am
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

I have to see the original feed.

May 25, 2018
5:32 am
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline

orginal feed: 

 

Login to see the quote

 

pls remove this post when you get it. tnx. 

this is not only question about language but also a  and tag   and  tags. tnx. 

edit: and yes I use a MODEL for XML section names

May 31, 2018
5:14 am
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

As I said, you should use the “Custom Fields” box as it explained in the manual: Login to see this link

E.g.:

Login to see the quote

Or maybe I just didn’t get your question… Be more specific please.

May 31, 2018
4:32 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline

>As I said, you should you the “Custom Fields” box as it explained in the manual

no, you do not understand me.
After all, it is obvious that I have to use custom fields. 

example

<person>
<person_detail_1>aaa</person_detail_1>
<person_detail_2>bbb</person_detail_2>
</person>

 

and person->person

this is the work base over xml I wrote that the problem is that it’s written to array!

i give you copy paste from mysql. 

a:2:{i:0;s:6:”aaa”;i:1;s:4:”bbb”;}

my question was:
how to convert this variable to get remove of this array and save everything in custom fields after the decimal.  ” aaa, bbb “

why? because yoast sees this variable as array. and does not display it.
the only thing I need is to rewrite this variable from the array to one after the comma. but not array.
thank you in advance, I hope you understand me now. 

tnx

June 2, 2018
12:21 pm
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

You can use the following PHP code (it will turn the array into a comma-delimited string):

Login to see the code

Please find the detailed description here: Login to see this link

June 3, 2018
1:09 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline

Perfect. It works great. thank you.

June 3, 2018
1:17 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline

I still have a question. are there possibilities to these arrays.
from this example, we have a person and a female male. What to do if I want to make only the first attributes and the rest forgeted (well no use it)?
Thank you for your help.

June 3, 2018
11:04 pm
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline

Something like this in the custom fields box:

performerId->name

June 6, 2018
2:45 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline
10sp_Permalink sp_Print
0

Hi can you look on this code?

if (isset($post[‘custom_fields’][‘appearance’]) && is_array($post[‘custom_fields’][‘appearance’])) {
$post[‘custom_fields’][‘appearance_low’] = implode(‘, ‘, $post[‘custom_fields’][‘appearance’]);
$post[‘custom_fields’][‘appearance_cap’] = ucwords(strtolower(implode(‘, ‘, $post[‘custom_fields’][‘appearance’])));
}

is save me a appearance if is array in two places in appearance_low and appearance_cap …. but

what if appearance is not a array ? i need add a else? and where i need add a else or just don’t add else and operate on only a custom field (main from plugin settings)

 

tnx.

June 6, 2018
3:40 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline
11sp_Permalink sp_Print
0

The problem is when in the age field there is only one value then the rewrite (implode) adds “comma” and I have something like “, blond” saved in the custom field. And I do not know how to get rid of this comma.
I thought that first I will add rewrite variables to uppercase letters and then the plugin will check in custom php but that’s how it does not want to work.

(first) wrote a haircolour in ucwords

$post[‘custom_fields’][‘haircolor_t’] = ucwords(strtolower($post[‘custom_fields’][‘haircolor’]));

after it….

check if haircolor is array and wrote two   times   haircolor_e and haircolor_t

if (isset($post[‘custom_fields’][‘haircolor’]) && is_array($post[‘custom_fields’][‘haircolor’])) {
$post[‘custom_fields’][‘haircolor_e’] = implode(‘, ‘, $post[‘custom_fields’][‘haircolor’]);
$post[‘custom_fields’][‘haircolor_t’] = ucwords(strtolower(implode(‘, ‘, $post[‘custom_fields’][‘haircolor’])));
}

 

I don’t know how to keep (don’t implode when value is not array. and I wast tinking a this code is ok but no. 

tnx. for help

June 8, 2018
4:38 am
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline
12sp_Permalink sp_Print
0

magneto664 said
Hi can you look on this code?

if (isset($post[‘custom_fields’][‘appearance’]) && is_array($post[‘custom_fields’][‘appearance’])) {
$post[‘custom_fields’][‘appearance_low’] = implode(‘, ‘, $post[‘custom_fields’][‘appearance’]);
$post[‘custom_fields’][‘appearance_cap’] = ucwords(strtolower(implode(‘, ‘, $post[‘custom_fields’][‘appearance’])));
}

is save me a appearance if is array in two places in appearance_low and appearance_cap …. but

what if appearance is not a array ? i need add a else? and where i need add a else or just don’t add else and operate on only a custom field (main from plugin settings)

Just add these two lines of code after yours:

Login to see the code

June 11, 2018
1:29 pm
Avatar
magneto664
Member
Members
Forum Posts: 12
Member Since:
July 1, 2017
sp_UserOfflineSmall Offline
13sp_Permalink sp_Print
0

Its almost give me all what I need but in some fields “,” is on the end of the line 

I try with this preg_replace(‘/,$/’,

but this don’t give me noting did I do this ok? tnx

June 12, 2018
5:42 am
Avatar
CyberSEO
Admin
Forum Posts: 3709
Member Since:
July 2, 2009
sp_UserOfflineSmall Offline
14sp_Permalink sp_Print
0

magneto664 said
Its almost give me all what I need but in some fields “,” is on the end of the line 

I try with this preg_replace(‘/,$/’,

but this don’t give me noting did I do this ok? tnx  

Login to see the code

Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 541

Currently Online:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 84

s.baryshev.aoasp: 64

Freedom: 61

MediFormatica: 49

B8europe: 47

saviulisse67: 45

Member Stats:

Guest Posters: 338

Members: 2667

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1549

Posts: 7829

Newest Members:

mark.frontiercreative, fairriverllc, josepatricioperalta, goran.o.aroga, betomanzoli, monefff

Administrators: CyberSEO: 3709