2

I'm setting up a twitter feed with craft.twitter.get() and I need to convert a dropdown value to an integer. Here is my code far:

{% set cacheTime = sidebarBlock.twitterFeedCacheTime %}
{% set tweets = craft.twitter.get('statuses/user_timeline.json?screen_name='~ sidebarBlock.twitterFeedUsername ~'&count='~ sidebarBlock.twitterFeedTweetCount ~ '&', { exclude_replies: sidebarBlock.twitterFeedIncludeReplies, include_rts: sidebarBlock.twitterFeedIncludeRetweets, }, {}, true, cacheTime) %}
{% if tweets %}
<div class="twitter-feed">
  <h4>{{ sidebarBlock.twitterFeedTitle }}</h4>
  {% for tweet in tweets %}
  <div class="tweet">
    <p>
      <a class="twitter-screen-name" href="http://twitter.com{{ tweet.user.screen_name|raw }}" target="_blank">@{{ tweet.user.screen_name|raw }}</a>: <span class="tiny">{{ tweet.created_at |nicetime('m-d-Y') }}</span><br/>
      {{tweet| tweetLink(newWindow='true') | raw}}
    </p>
  </div>
  {% endfor %}
</div>
{% endif %} 

It seems that no matter what I try on twitterFeedcacheTime it returns a string to integer conversion error:

Object of class Craft\SingleOptionFieldData could not be converted to int

/craft/app/etc/cache/FileCache.php(85)

73      * @param  string  $value  The value to be cached
74      * @param  integer $expire The number of seconds in which the cached value will expire. 0 means never expire.
75      * @return boolean true    If the value is successfully stored into cache, false otherwise
76      */
77     protected function setValue($key, $value, $expire)
78     {
79         if (!$this->_gced && mt_rand(0, 1000000) < $this->getGCProbability())
80         {
81             $this->gc();
82             $this->_gced = true;
83         }
84 
85         if($expire <= 0)
86         {
87             $expire = 31536000; // 1 year
88         }
89 
90         $expire += time();
91 
92         $cacheFile = $this->getCacheFile($key);
93 
94         if ($this->directoryLevel > 0)
95         {
96             IOHelper::createFolder(IOHelper::getFolderName($cacheFile), IOHelper::getWritableFolderPermissions());
97         }
  • 1
    Would you be willing to add the literal error output? I think you'd then have a flawless question. (And a more searchable one for posterity.) – Matt Stein Jun 13 '14 at 17:07
4

Give this a shot:

 {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
| improve this answer | |
  • OK - give this a shot: {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %} – Dan Ott Jun 13 '14 at 17:42
  • I'm still learning about stackexchange etiquette - i wasn't sure if i should edit my original answer or add a new one. SE didn't seem to want me to add another... – Dan Ott Jun 13 '14 at 17:43
  • @DanOtt Editing and improving answers is a good thing. You're doing it right! – Matt Stein Jun 13 '14 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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