<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Q &#187; ExpressionEngine</title>
	<atom:link href="http://www.mc2design.com/blog/category/expressionengine/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mc2design.com/blog</link>
	<description>Web development and marketing from the squares at MC² Design Group</description>
	<lastBuildDate>Tue, 16 Feb 2010 22:53:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Limit Characters or Words in&#160;ExpressionEngine</title>
		<link>http://www.mc2design.com/blog/limit-characters-of-variable-in-expressionengine</link>
		<comments>http://www.mc2design.com/blog/limit-characters-of-variable-in-expressionengine#comments</comments>
		<pubDate>Tue, 05 May 2009 18:10:21 +0000</pubDate>
		<dc:creator>Jarrett M. Barnett</dc:creator>
				<category><![CDATA[ExpressionEngine]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://www.mc2design.com/blog/?p=287</guid>
		<description><![CDATA[The more I use ExpressionEngine, the more I love it as there&#8217;s a solution for anything that I can find a need&#160;for.
I couldn&#8217;t find a parameter that I could use in ExpressionEngine (that was already built in) that limited how many characters were used from a variable. In PHP, you could use substr() and trim(), [...]]]></description>
			<content:encoded><![CDATA[<p>The more I use ExpressionEngine, the more I love it as there&#8217;s a solution for anything that I can find a need&nbsp;for.</p>
<p>I couldn&#8217;t find a parameter that I could use in ExpressionEngine (that was already built in) that limited how many characters were used from a variable. In PHP, you could use substr() and trim(), but I wanted to avoid using PHP in ExpressionEngine as much as possible. So after a bit of searching I found this ExpressionEngine plugin called &#8220;<a href="http://expressionengine.com/downloads/details/character_limiter/" rel="nofollow" title="ExpressionEngine Character Limiter">Character Limiter</a>&#8221; which allows me to use the following&nbsp;expression:</p>
<pre class="brush: php">
{exp:char_limit total=&quot;100&quot;}
    {variable}
{/exp:char_limit}
</pre>
<p>Simple as&nbsp;that.</p>
<p>You may find that you would rather limit the number of words outputted. To do this, use the <a href="/tag/expressionengine">ExpressionEngine</a> plugin called &#8220;<a href="http://expressionengine.com/downloads/details/word_limit_plus/" rel="nofollow" title="ExpressionEngine Word Limit Plus">Word Limit Plus</a>&#8220;.  Upload &#8220;pi.word_limit_plus.php&#8221; to the /system/plugins/ directory, and use the following expression to limit the amount of words&nbsp;outputted:</p>
<pre class="brush: php">
{exp:word_limit_plus if_exceeds=&quot;600&quot; stop_after=&quot;500&quot; the_link=&quot;&lt;a href=&#039;{title_permalink=weblog/comments}&#039;&gt;MORE...&lt;/a&gt;&quot;}
   {variable}
{/exp:word_limit_plus}
</pre>
<p>I haven&#8217;t used this plugin yet, but from the &#8220;Word Limit Plus&#8221; plugin documentation, the &#8220;if_exceeds&#8221; parameter is the amount of words that need to be met before the text is triggered to be truncated. The amount of words that the text string would be truncated TO is the &#8220;stop_after&#8221; parameter.&nbsp;</p>
<p>Again I haven&#8217;t confirmed this, but if I am correct, then a paragraph that has more than 600 words would be truncated to only be 500 words, while a paragraph of 599 words would not be truncated at all. I imagine this is to prevent from having blogs posts that truncate and leave out only a few words (obviously if there&#8217;s only a few more words left to display of a blog post, why not just display them rather than truncate the extra words&nbsp;out).</p>
<p>The &#8220;the_link&#8221; parameter is not required, but from what I can tell, its tacked onto the end of the outputted text and serves as a way to display a &#8220;Read more&#8230;&#8221; link at the end of a blog&nbsp;post.</p>
<p>A good side note is through my research of the &#8220;Word Limit Plus&#8221; ExpressionEngine plugin, I did find that because the &#8220;Word Limit Plus&#8221; looks for spaces (to determine the word count), consecutive spaces may cause an&nbsp;error.</p>
<p>None-the-less, the ExpressionEngine &#8220;Word Limit Plus&#8221; plugin could be useful for summarizing blog posts on your home page, building a custom RSS feed to be used for feeding data to <a href="http://en.wikipedia.org/wiki/Twitter" rel="nofollow" title="Twitter">Twitter</a>, or simply feeding data to another portion of your site. I won&#8217;t go into too much detail about it, but I&#8217;m sure the possibilities are fairly&nbsp;endless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mc2design.com/blog/limit-characters-of-variable-in-expressionengine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Fields Extension in&#160;ExpressionEngine</title>
		<link>http://www.mc2design.com/blog/random-fields-extension-in-expressionengine</link>
		<comments>http://www.mc2design.com/blog/random-fields-extension-in-expressionengine#comments</comments>
		<pubDate>Fri, 01 May 2009 16:35:30 +0000</pubDate>
		<dc:creator>Jarrett M. Barnett</dc:creator>
				<category><![CDATA[ExpressionEngine]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://www.mc2design.com/blog/?p=271</guid>
		<description><![CDATA[Early last month I posted two different ways to have random fields in ExpressionEngine stating that &#8220;&#8230;in ExpressionEngine, a &#8216;random number&#8217; expression has yet to exist&#8221;. Well I hate to say but I was wrong! In fact, ExpressionEngine comes with a &#8220;Randomizer&#8221; plugin built right in. Simply navigate to: Admin > Utilities > Plugin&#160;Manager.
However, there [...]]]></description>
			<content:encoded><![CDATA[<p>Early last month I posted <a href="http://www.mc2design.com/blog/random-in-expressionengine-with-without-php">two different ways to have random fields in ExpressionEngine</a> stating that &#8220;&#8230;in ExpressionEngine, a &#8216;random number&#8217; expression has yet to exist&#8221;. Well I hate to say but I was wrong! In fact, ExpressionEngine comes with a &#8220;Randomizer&#8221; plugin built right in. Simply navigate to: Admin > Utilities > Plugin&nbsp;Manager.</p>
<p>However, there is an inconvenience with the &#8220;Randomizer&#8221; plugin. It&#8217;s a pain to use!&nbsp;</p>
<p>The instructions state:<br />
-Open this file: /plugins/pi.randomizer.php<br />
-Fill the array with as many quotes as you want.<br />
-Then place the following tag in any of your templates: {exp:randomizer:set_one}</p>
<p>A friendly no thanks to that plugin. So I did a bit of searching and found a plugin (by a different author) called &#8220;<a href="http://expressionengine.com/downloads/details/randomizer_plus/" target="_blank" rel="nofollow">Randomizer Plus</a>&#8221; and its the best solution I&#8217;ve found so far to randomization within ExpressionEngine&#8217;s template&nbsp;system.</p>
<p>Setting it up is also really easy. Take the pi.randomizer_plus.php file from the downloaded zip archive file, and upload it into your &#8216;plugins&#8217; directory, located in /system/plugins.&nbsp;</p>
<p>From there, its just a matter of using the appropriate tag in your page template, and to specify the seperator&nbsp;(delimiter):</p>
<pre class="brush: php">
{exp:randomizer_plus separator=&quot;{OR}&quot;}
Random Value 1
{OR}
Random Value 2
{OR}
Random Value 3
{/exp:randomizer_plus}
</pre>
<p>Looks clean and super easy to use! It makes you just love ExpressionEngine just that much&nbsp;more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mc2design.com/blog/random-fields-extension-in-expressionengine/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Random Number in ExpressionEngine With &amp; Without&#160;PHP</title>
		<link>http://www.mc2design.com/blog/random-in-expressionengine-with-without-php</link>
		<comments>http://www.mc2design.com/blog/random-in-expressionengine-with-without-php#comments</comments>
		<pubDate>Wed, 08 Apr 2009 20:49:09 +0000</pubDate>
		<dc:creator>Jarrett M. Barnett</dc:creator>
				<category><![CDATA[ExpressionEngine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://www.mc2design.com/blog/?p=256</guid>
		<description><![CDATA[The rand() function in PHP is a quick and easy way to have a nice random number generated. Without it, faking randomization can quickly become cumbersome. After all, a random number has so many uses. Maybe you want to display a random testimonial on each page load, a featured blog post, or even use a [...]]]></description>
			<content:encoded><![CDATA[<p>The rand() function in PHP is a quick and easy way to have a nice random number generated. Without it, faking randomization can quickly become cumbersome. After all, a random number has so many uses. Maybe you want to display a random testimonial on each page load, a featured blog post, or even use a different stylesheet.&nbsp;</p>
<p>To get a random number with ExpressionEngine, we can go the PHP route, or the non-PHP route. Going the PHP route is obviously easier to output and write the markup for (not to mention, is truely &#8220;random&#8221;), but enabling PHP in your templates may not be your answer; especially if you don&#8217;t want users [who have the ability to create/edit blog posts] have the power to do anything that PHP would allow them to do (such as outputting normally unobtainable data from the&nbsp;database).</p>
<p>Unfortunately, in ExpressionEngine, a &#8220;random number&#8221; expression has yet to exist; however, one of the nice things about ExpressionEngine is the ability to process PHP at the flip of a switch.&nbsp;</p>
<p>The PHP Solution:<br />
First, turn on PHP processing in: Templates (tab) > Template Preferences Manager (link) > Allow PHP (dropdown)</p>
<p>Then we simply assign the rand() to a variable, and check against that variable to output&nbsp;accordingly.</p>
<pre class="brush: php">
&lt;?php 

$random_number = rand(0,6); 

if ($random_number == 1) { echo &#039;&lt;img src=&quot;/assets/images/image1.png&quot; /&gt;&#039;; }
elseif ($random_number == 2) { echo &#039;&lt;img src=&quot;/assets/images/image2.png&quot; /&gt;&#039;; }
elseif ($random_number == 3) { echo &#039;&lt;img src=&quot;/assets/images/image3.png&quot; /&gt;&#039;; }
elseif ($random_number == 4) { echo &#039;&lt;img src=&quot;/assets/images/image4.png&quot; /&gt;&#039;; }
elseif ($random_number == 5) { echo &#039;&lt;img src=&quot;/assets/images/image5.png&quot; /&gt;&#039;; }
elseif ($random_number == 6) { echo &#039;&lt;img src=&quot;/assets/images/image6.png&quot; /&gt;&#039;; }

// ensures an image is displayed even when no other conditions are met (in this case, it really only displays when random_number = 0)
else { echo &#039;&lt;img src=&quot;\/assets\/images\/image0.png&quot; \/&gt;&#039;; } 

?&gt;
</pre>
<p>For those that prefer to avoid PHP, here&#8217;s a quick way to (in a way) fake a random number. I figured a good way to do this was using the {current_time}, but only the seconds portion. Granted, its not the most elegant solution, but it gets the job&nbsp;done.</p>
<p>The Non-PHP&nbsp;Solution:</p>
<pre class="brush: php">
{!-- Sets current time (seconds) to the variable &#039;current_time_seconds&#039; --}
{assign_variable:current_time_seconds=&quot;{current_time format=&quot;%s&quot;}&quot;}

{!-- %s = Seconds range: 00-59 --}
{!-- Check current time in seconds and displays a different image based on current time in seconds --}

{!-- displays if 1-9 --}
{if {current_time_seconds} &gt; 0 &amp;&amp; {current_time_seconds} &lt; 10}
&lt;img src=&quot;/assets/images/image1.png&quot; /&gt;

{!-- displays if 11-19 --}
{if:elseif {current_time_seconds} &gt; 10 &amp;&amp; {current_time_seconds} &lt; 20}
&lt;img src=&quot;/assets/images/image2.png&quot; /&gt;

{!-- displays if 21-29 --}
{if:elseif {current_time_seconds} &gt; 20 &amp;&amp; {current_time_seconds} &lt; 30}
&lt;img src=&quot;/assets/images/image3&quot; /&gt;

{!-- displays if 31-39 --}
{if:elseif {current_time_seconds} &gt; 30 &amp;&amp; {current_time_seconds} &lt; 40}
&lt;img src=&quot;/assets/images/image4.png&quot; /&gt;

{!-- displays if 41-49 --}
{if:elseif {current_time_seconds} &gt; 40 &amp;&amp; {current_time_seconds} &lt; 50}
&lt;img src=&quot;/assets/images/image5.png&quot; /&gt;

{!-- displays if 51-59 --}
{if:elseif {current_time_seconds} &gt; 50 &amp;&amp; {current_time_seconds} &lt; 60}
&lt;img src=&quot;/assets/images/image6.png&quot; /&gt;

{!-- displays if seconds don&#039;t match any of the conditions above (basically the following times in seconds: 00,10,20,30,40,50) --}
{if:else}
&lt;img src=&quot;/assets/images/image0.png&quot; /&gt;

{/if}
</pre>
<p>The non-PHP solution can be a great solution for someone who doesn&#8217;t want a random image &#8220;every single time&#8221; (for the visitors who are clicking through pages within seconds of&nbsp;eachother).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mc2design.com/blog/random-in-expressionengine-with-without-php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
