<p>Give this a shot:</p>

<pre><code> {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
</code></pre>

CC BY-SA 3.0
2014-06-13T17:42:03.590Z
OK - give this a shot: 

    {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
Dan Ott
CC BY-SA 3.0
2014-06-13T17:43:26.943Z
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
CC BY-SA 3.0
2014-06-13T18:09:44.493Z
@DanOtt Editing and improving answers is a good thing. You're doing it right!
Matt Stein
CC BY-SA 3.0
2014-06-13T17:24:18.940Z
2014-06-13T19:10:22.377Z
2014-06-13T19:10:22.377Z
Dan Ott
<p>I'm setting up a twitter feed with <code>craft.twitter.get()</code> and I need to convert a dropdown value to an integer. Here is my code far:</p>

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

<p>It seems that no matter what I try on <code>twitterFeedcacheTime</code> it returns a string to integer conversion error:</p>

<pre><code>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-&gt;_gced &amp;&amp; mt_rand(0, 1000000) &lt; $this-&gt;getGCProbability())
80         {
81             $this-&gt;gc();
82             $this-&gt;_gced = true;
83         }
84 
85         if($expire &lt;= 0)
86         {
87             $expire = 31536000; // 1 year
88         }
89 
90         $expire += time();
91 
92         $cacheFile = $this-&gt;getCacheFile($key);
93 
94         if ($this-&gt;directoryLevel &gt; 0)
95         {
96             IOHelper::createFolder(IOHelper::getFolderName($cacheFile), IOHelper::getWritableFolderPermissions());
97         }
</code></pre>

CC BY-SA 3.0
2014-06-13T17:07:46.457Z
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
<hash><string><conversion>
How can I convert a dropdown field value to an integer within a hash?
# How can I convert a dropdown field value to an integer within a hash?

(Asked by: username_0 on 2014-06-13)

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 %}

  {{ sidebarBlock.twitterFeedTitle }}
  {% for tweet in tweets %}
  
    
      @{{ tweet.user.screen_name|raw }}: {{ tweet.created_at |nicetime('m-d-Y') }}
      {{tweet| tweetLink(newWindow='true') | raw}}
    
  
  {% endfor %}

{% 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         }

**Tags:** hash, string, conversion

> **Comments:**
> **username_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.)  

---

## 1 answers

### Answer by username_2 on 2014-06-13. Score: 4 | Accepted answer

Give this a shot:
 {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}

> **Comments:**
> **username_2**: OK - give this a shot:       {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}  
> **username_2**: 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...  
> **username_1**: @DanOtt Editing and improving answers is a good thing. You're doing it right!  

---

