Answers.Body: <p>Give this a shot:</p>
  
  <pre><code> {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T17:42:03.590Z
Answers.Text: OK - give this a shot: 
  
      {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
Answers.UserDisplayName: Dan Ott
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T17:43:26.943Z
Answers.Text: 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...
Answers.UserDisplayName: Dan Ott
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T18:09:44.493Z
Answers.Text: @DanOtt Editing and improving answers is a good thing. You're doing it right!
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T17:24:18.940Z
Answers.LastActivityDate: 2014-06-13T19:10:22.377Z
Answers.LastEditDate: 2014-06-13T19:10:22.377Z
Answers.UserDisplayName: Dan Ott
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-13T17:07:46.457Z
Comments.Text: 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.)
Comments.UserDisplayName: Matt Stein
Tags: <hash><string><conversion>
Title: How can I convert a dropdown field value to an integer within a hash?
ThreadText: # 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 %}
  <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         }
  
  ```
  
  **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**: @username_2 Editing and improving answers is a good thing. You're doing it right!  
  
  ---
  
  