1

This question sureley can only be answered by people with some drupal experience. As I have quite different and complex views, which I need to control totally, I need to come to a design decision. Which way has the highest performance putting out view content?

  1. Define the fields in the Views UI, don't output them and use them in custom text? Like described here: http://highrockmedia.com/blog/rewriting-drupal-views-output-custom-theming-css
  2. Provide a views-view-field--field-machine-name-of-field.tpl, get the $row['_field_data']['nid']['entity']->{'field_machine_name'} and iterate over its contents?
  3. Another or better way of which I'm not aware off?

Example, of how a result could look like:

<div itemscope itemtype="http://schema.org/Product">
  <img itemprop="image" src="dell-30in-lcd.jpg" />
  <span itemprop="name">Dell UltraSharp 30" LCD Monitor</span>
  <div itemprop="aggregateRating"
    itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">87</span>
    out of <span itemprop="bestRating">100</span>
    based on <span itemprop="ratingCount">24</span> user ratings
  </div>
  <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
    <span itemprop="lowPrice">$1250</span>
    to <span itemprop="highPrice">$1495</span>
    from <span itemprop="offerCount">8</span> sellers
  Sellers:
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <a itemprop="url" href="save-a-lot-monitors.com/dell-30.html">
     Save A Lot Monitors - $1250</a>
  </div>
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
    <a itemprop="url" href="jondoe-gadgets.com/dell-30.html">Jon Doe's Gadgets - $1350</a>
  </div>
</div>
5
  • 1
    You can normalise the performance by turning caching on for the View; that will let you choose whichever method you prefer (I'd prefer a template, for example, but you may prefer the UI method)
    – Clive
    Oct 16, 2014 at 16:38
  • @Clive maybe i'm being niave but most of my clients expect a "real time" report for like any view ... how can views caching play well with "new content is there and when i goto the page i shouldnt wait for 5 minute intervals (cache effects)"
    – tenken
    Oct 16, 2014 at 17:22
  • 1
    @tenken Views Content Cache module is exactly for that problem. It caches the view till a new content of a selected content type added or updated. Oct 16, 2014 at 19:30
  • 1
    Moreover, you can more precisely clear any cache in a hook or whatever logic you want using cache_clear_all($cid). Oct 16, 2014 at 19:32
  • 1
    Have a look at the new kid on the block, Views Accelerator. It is for sites that cannot be cached normally, and it has a performance summary on the view so you can do comparisons. Oct 17, 2014 at 4:19

1 Answer 1

1

I would go for Template based solution for the sake of maintainability and flexibility. For example, if you are using the same field in two different views, you can use a .tpl file that applies to all views that have that field. But if you depend on Views UI, you will have to configure each field in every view separately which may complicate things in the long run. Also, the fewer access to database to retrieve configuration the better.

1
  • Sounds good, thank you. And is the way of going over $row['_field_data']['nid']['entity']->{'field_machine_name'} the way to do? Or is there another approach? Oct 16, 2014 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.