Call a field value in template via code

More
11 years 1 month ago #41507 by strgg
Hi

I want to call label and value of field77 in
components/com_flexicontent/templates/mytheme
by code.

The www.flexicontent.org/documentation/faq/7...a-template-file.html described does not work
Code:
$fvals = @$this->item->fields['field19']->value;

How to call single labels, values and arrays (par ess. multiple images) and those properties like image->originalname?

thx

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

More
11 years 1 month ago #41510 by ggppdk
Hello

if you are in category view it is different, (i have updated the article)
(and yes e.g. the original is there too)

but you need to use:

in item view
$item or $this->item

and in category view
$item or $items[$i] or this->items[$i]

about image field you can use the properties that are inside the value,
but it may be difficult to calculate the thumbnail path, so better use these array (each of them is an array)
www.flexicontent.org/documentati ... field.html

$item->fields->thumbs_src[]
$item->fields->thumbs_src[]
$item->fields->thumbs_src[]
$item->fields->thumbs_src[]
$item->fields->thumbs_src[]

(note access to original image maybe protect, see image parameter, ok usually you will not use original image in template because it will also be slow to download or to process)

Regards


-- 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
11 years 1 month ago #41515 by strgg
Hi ggppdk

thanks for answering.
Code:
$fvals = $item->fields['field19']->value; AND $fvals = $this->item->fields['field19']->value; var_dump($fvals);

don't work to be called within
Code:
components/com_flexicontent/templates/mytheme/item.php

Note:
- i tried with different fieldX
- data IS available in __flexicontent_fields_item_relations
- change in item.php DOES take effect in frontend
->there must be something wrong with the way to call

Analysing the code
i would have to call
Code:
$this->item->fieldvalues[77][0]

messy and ressource intensive to pack it into a generic class if the majority of the values are not needed, why call it anyway? the $this->item object is so huge and more than 95% of the values are not needed in ANY case.

thanks

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

More
11 years 1 month ago #41519 by ggppdk

strgg wrote: messy and ressource intensive to pack it into a generic class if the majority of the values are not needed, why call it anyway? the $this->item object is so huge and more than 95% of the values are not needed in ANY case.

thanks


Hello

unneeded? huge? so $item is MBs ?
well no it is a few KBs, so "huge" sound strange

and the field values are retrieved via a single query, not just in item view but in category view (content lists views) too

Have you measured the cost of retrieving field values?

we we have taken time to profile the code and look for slow parts, and provide statistics for it,

you optimize what is costly by testing and by theory e.g. you prefer O(n) to O(n*n),
not what looks like being costly, this way you end up creating slower code

-- you can go to FLEXIcontent component setting and enable inside the first TAB "options" enable the parameter for displaying performance statistics

about ->fieldvalues yes that is probably a mistake in the FAQ article, i will check and update the FAQ

Regards


-- 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
11 years 1 month ago #41524 by strgg
Hi ggppdk

Thanks for answering

unneeded? huge? so $item is MBs ?

It's not only the KB's but how you get it.

I made some performance tests with 400 records with other free CCK's, here the results:

Categories (12 on items first page):
Joomla content: 100%
Pages and Items: 126%
Form2content: 148%
Seblod: 349%
Flexicontent: 428%

Items:
Joomla content: 100%
Pages and Items: 111%
Form2content: 135%
Seblod: 240%
Flexicontent: 296%

The content tested was only text and 1 picture.

reasons:
flexi implements by default libs and styling.
flexi provides the non-coder a UI for placing the content in theme which requires rerendering the content.
unnecessary calls to database
minor, but scripts and css could be optimized.

don't understand me wrong, i don't think flexi is bad. it's just a test i made and share here.

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

More
11 years 1 month ago #41526 by ggppdk
Hello

1. we have tested with 10,000+ items per category,
when optimizing,
do a comparison there and you will see FLEXIcontent is faster than everything else that displays similar content


2. For medium-sized sites FLEXIcontent will be faster than anything else that displays content with similar capabilities

3. For large sites it will be faster or a lot faster than other solutions doing the some functionality

also are you speaking of 1st run of category view ? then extra times is spent on internal caching, or do you have active filters ?

about the performance that you posted it is meaning-full if you mention what content is displayed

and yes for very small sites Joomla will be faster, but FLEXIcontent has a very scalable performance, as sites grows (EXCEPT for faceted filters, so don't display 20 faceted filters in an 20,000 + items website, despite these being optimized too)

e.g. the RENDERING of extra field have a cost,
that depends on the field
e.g. you may trigger content plugins in individual fields

but this is fixed and same if your page is e.g. 20 items

try showing items in a site with 2,000 + items without extra fields and doing various different orderings to see the effect

- try using the backend items manager when you have 10,000+ items, and applying various orderings

compare times with Joomla or with other components

PLEASE enable performance statistics in FLEXIcontent component under options TAB, you will know where time is spent for every important part of FLEXIcontent , thus optimizing FLEXIcontent is much easier

Regards


-- 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.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.341 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