Will Hunting

Developer

Isaac Raway - Airways

3rd Party (Free)

13 downloads (last 90 days)

Creative Commons Attribution No Derivatives Download v2.5.7

EE Version Support

  • ExpressionEngine 1.x
  • ExpressionEngine 2

Compatibility

If an item is crossed out, it might be untested, not applicable or incompatible. Contact the developer to be sure.

  • Updater
  • Multi Site Manager
  • Stand Alone Entry Form
  • Low Variables
  • Content Elements
  • Better Workflow
  • Matrix
  • Grid
  • Webservice
  • Publisher

Requirements

  • jQuery for the Control Panel

Add-On Type(s)

Plugin

Tags

Provides a math template tag capable of performing relatively complex mathematical evaluations.

This tag provides class that provides math evaluation can handle relatively complex evaluations, including basic math functions such as round() and rand().

There are two types of tags available: a single tag that evaluates math expressions, and a pair tag that adds a new syntax for evaluation of expressions in-line with other conditional logic.

Single Tag

Basic math:

12 * 12 = {exp:will_hunting:solve exp="12 * 12"}

Generating previous and next integers for custom pagination links from a page parameter (in this case retrieved using Super Globals):

prev_page = {exp:will_hunting:solve exp="{get:page} - 1"}
next_page = {exp:will_hunting:solve exp="{get:page} + 1"}

Tag Pair

The tag pair is meant to be wrapped around an entire loop of content or other large section where you would like to perform multiple math operations, and introduces support for a much more functional and simpler syntax. This can often times completely replace PHP since it still includes support for the functions listed at the end of the page.

The pair tag is shown in this example:

{exp:will_hunting:solve_pair}
    {$one_fourty_four=12*12}
    {$prev_page={get:page}-1}
    {$next_page={get:page}+1}
{/exp:will_hunting:solve_pair}

Another example for the experimental syntax, using conditionals to show a fake no results message. Note in this example, x is a custom field on the only weblog in the test instance, and none of the entries have x set to 3.

Note: All variables in Will Hunting must start with a $ sign so that it can tell them apart from normal ExpressionEngine variables.

{exp:will_hunting:solve_pair}
  {$count=0}
  {$no_results=0}
  start count = {$count}
  {exp:weblog:entries parse="inward"}
    {if no_results}
      Real no results!
      {$no_results=1}
    {/if}
    {if x == 3}{
      {entry_id} {title}
      {$count=$count+1}
    {/if}
  {/exp:weblog:entries}

  count = {$count}
  {if {$count} == 0}
      {if {$no_results} == 0}
          Fake no entries!
      {/if}
  {/if}
{/exp:will_hunting:solve_pair}

The tag pair also creates a new layer of conditional evaluation which occurs in order along with expression evaluations, at the time that the will_hunting tag is called.


{exp:will_hunting:solve_pair}
    {$count=0}

    {$count=$count+1}
    one = {$count}<br/>
    {if {$count} > 1}
        Greater than 1 ({$count})!<br/>
    {/if}
    
    {$count=$count+1}
    two = {$count}<br/>
    {if {$count} > 1}
        Greater than 1 ({$count})!<br/>
    {/if}
{/exp:will_hunting:solve_pair}

Will Hunting also supports future variable references in the form of {%variable_name}. These variables will br parsed as the very last action to allow their final values to be references before they are defined. No further manipulation can be done on the variables at this point.


{exp:will_hunting:solve_pair}
    Final %count: {%count}
{$count=0} {$count=$count+1} {$count=$count+1} Last normal count: {$count}
{/exp:will_hunting:solve_pair}

Functions

Will Hunting provides the following functions in addition to basic math operators.

abs(n)

Returns the absolute value of n.

ceil(n)

Returns the next highest integer value by rounding up value if necessary.

floor(n)

Returns the next lowest integer value by rounding down value if necessary.

int(n)

Returns the integer value of n, using base 10 for the conversion.

max(n1,..)

Returns the largest of the provided numbers.

min(n1,...)

Returns the smallest of the provided numbers.

mod(n1, n2)

Performs a mod operation on n1/n2.

rand(n1, n2)

Returns a pseudo-random integer from n1 to n2.

round(n, p)

Rounds n to precision p.

Additional Functions?

If you need any additional functions please let me know in the forum and I’ll add them!

Other MetaSushi stuff…

ProForm

Be sure to check out my form module ProForm!

ProForm is the first and most powerful drag and drop form manager for ExpressionEngine 2.0. It’s designed to make creation and management of contact forms and other types of public forms easier for developers, content editors, and visitors - everyone who needs to interact with forms in any way.

With ProForm, one line of template code can render simple contact forms, or complex multistep forms all created easily through its drag and drop form builder UI. ProForm also gives you precise control over your forms’ markup through a full template pair - rendering a form is as easy as rendering your site’s content - just the way it should be in ExpressionEngine.

MetaSushi EE Add-ons Newsletter

To stay up to date with the latest ExpressionEngine add-on news from MetaSushi, be sure to subscribe to the MetaSushi EE Add-ons Newsletter today (very low volume).

Download Will Hunting

EE Support Downloads Add-On Version Release Date
Not Specified Download 2.5.7 Sep 15, 2011

This entry was created December 7, 2010, 12:27 pm.
This entry was last updated December 10, 2012, 4:43 pm.

Disclaimer: Information about ExpressionEngine add-ons is provided as a service to you, the user, and every member of the ExpressionEngine community. devot:ee is not responsible if you hose, mangle, wreck, or otherwise destroy your EE website by installing an add-on that you found out about at this site, regardless of its rating, Favorites status, commercial or free status, or general popularity. Caveat EEmptor!

Returns: devot:ee has a 30-day return policy on all commercial add-ons sold through devot-ee.com. If you need to return an add-on, do not go to the developer or the developer's site, but rather visit our returns page at https://devot-ee.com/returns to initiate your return. If you have questions, email support@devot-ee.com.

There are no reviews for this add-on yet.

What are you waiting for? Rate it and review it!