HTML code in fields output?

More
7 years 6 months ago - 7 years 6 months ago #67825 by lipatovroman
Hi!
My mind, that fields output code should be clean.
Only values should be displayed.
Explain.
For example, I need to use item title for my needs.
I use construction :
Code:
echo $item->fields["title"]->display;

I hope to get clean item title:
Code:
Advanced SystemCare Free

but I get
Code:
<div style="display:inline" itemprop="name"> Advanced SystemCare Free </div>

So, I need to use strip_tags and str_replace, because this code contains extra HTML code and hidden symbols "\n", "\t".

And I need to do this each time, when I use fields for my needs.

Also, I know, that using styles instead classes is not very good idea. How you think?

So, I have question. If I use strip_tags and str_replace for 5-7 fields on item views page - does this affect to page speed loading?
Last edit: 7 years 6 months ago by lipatovroman.

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago #67830 by ggppdk
Replied by ggppdk on topic HTML code in fields output?
Hello

For item properties use:

$item->title
$item->alias
$item->description
$item->language
etc

For custom field values use:

$item->fieldvalues[45]; // 45 is the field ID of your field

See more here:
www.flexicontent.org/documentation/faq/7...stom-field-type.html


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
The following user(s) said Thank You: lipatovroman

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago #67837 by lipatovroman
Ok, it's clear.

But why fields output contains extra symbols?

Example:

I use text field with simple text, but when I check code for this field, this how it looks:



Ok, I copy this code to my editor:



It have tabulation symbols...


And I can't understand, how to get value of text field.

I use $item->fieldvalues[45]; // 45 is the field ID of your field

it displays - Array, no value.

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago #67838 by ggppdk
Replied by ggppdk on topic HTML code in fields output?

It have tabulation symbols...


Hello yes it has TABs and HTML , etc
it is because
->display is the HTML output of the field

$item->fieldvalues[45]
it displays - Array, no value.


In FLEXIcontent value of the fields are always an Array

So just get the first element of the array using:
[0]

you should of course check if field is empty or not (it may not have ...[0] at all)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago - 7 years 6 months ago #67840 by lipatovroman

ggppdk wrote: So just get the first element of the array using: [0]


Sorry, but how? How looks code, to get value from text field with ID 16?
Last edit: 7 years 6 months ago by lipatovroman.

Please Log in or Create an account to join the conversation.

More
7 years 6 months ago - 7 years 6 months ago #67845 by ggppdk
Replied by ggppdk on topic HTML code in fields output?
Hello

i gave you a link to a FAQ article above
Code:
$field_id = 16; $fvals = isset($item->fieldvalues[$field_id]) ? $item->fieldvalues[$field_id] : array(); if ( !count($fvals) ) { echo "Field is empty"; } foreach ($fvals as $v) { echo 'value' . $i . ' is : ' . $print_r($v,true) . '<br/>'; }


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 7 years 6 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.382 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline