1. Evo Documentation
      1. Administration
        1. Admin Users
          1. Admin Roles And Groups
          2. Reset your Password - Unblock your User
          3. Why Admin Users, Roles and Groups
        2. Friendly URL Solutions
        3. Moving Site
        4. Taking sites down for maintenance
        5. Upgrading
        6. Web Users
          1. Creating a Web User
          2. Web User Groups and Document Groups
          3. Why Web Users and Groups
      2. Content Editing
        1. Editing Resources
          1. Creating a Resource
          2. Edit a Resource
          3. Move a Resource
          4. Publishing a Resource
          5. Select a Template
        2. Evo Tags
          1. Document Variables
        3. Terminology
        4. The Admin Interface
        5. Who Should Read This
      3. Designing
        1. Adding Chunks
        2. Adding Snippets
        3. Adding Tags
          1. Resource Fields
        4. Cross References
        5. Document Caching
        6. Modifiers
          1. @ Modifiers
        7. Template Basics
      4. Developer's Guide
        1. API Reference
          1. DBAPI
            1. delete
            2. escape
            3. getInsertId
            4. query
            5. select
            6. update
          2. Document Object
          3. DocumentParser Object
            1. addEventListener
            2. changeWebUserPassword
            3. documentContent
            4. documentGenerated
            5. documentIdentifier
            6. documentListing
            7. documentMethod
            8. documentObject
            9. evalSnippet
            10. getAllChildren
            11. getCachePath
            12. getChildIds
            13. getDocumentChildren
            14. getDocumentChildrenTVarOutput
            15. getDocumentChildrenTVars
            16. getLoginUserID
            17. getLoginUserName
            18. getLoginUserType
            19. getManagerPath
            20. getParent
            21. getParentIds
            22. getUserData
            23. hasPermission
            24. isBackend
            25. isFrontend
            26. logEvent
            27. maxParserPasses
            28. minParserPasses
            29. regClientCSS
            30. runSnippet
            31. table_prefix
            32. tstart
            33. webAlert
        2. Chunks
        3. Modules
          1. How to create and run a module from within the Admin Interface
          2. Managing module dependencies
          3. Setting up configuration parameters
          4. Writing the module code
        4. Plugins
        5. Snippets
        6. Template Variables
          1. @ Bindings
            1. (at)CHUNK
            2. (at)DIRECTORY
            3. (at)DOCUMENT
            4. (at)EVAL
            5. (at)FILE
            6. (at)INHERIT
            7. (at)SELECT
            8. What are (at) Bindings
          2. Creating a Template Variable
          3. What are Template Variables
          4. Widgets
            1. DataGrid Widget
            2. Floater Widget
            3. Hyperlink Widget
            4. Marquee Widget
            5. Misc. Widget
            6. RichTextBox Widget
            7. Ticker Widget
            8. Viewport Widget
            9. What are Widgets
      5. Getting Started
        1. About Evo
        2. Basic Installation
    2. Evo Extras
      1. AjaxSearch
      2. AnythingRating
      3. Breadcrumbs
      4. directResize
      5. Ditto
        1. Examples
        2. Extenders
        3. Parameters
        4. Placeholders
      6. DocLister
        1. Examples
        2. Filters
        3. Main Parameters
        4. Notes for Developers
        5. Output Parameters
        6. Processing Before Output
      7. Easy 2 Gallery
      8. eForm
      9. EvoGallery
      10. FirstChildRedirect
      11. Jot
      12. MaxiGallery
      13. multiTV
        1. Examples
        2. Extras
        3. Installation
        4. Module
        5. Snippet
        6. Template Variable
      14. PHx
        1. Custom Modifiers
      15. Quill
      16. tagLinks
      17. TinyMCE
      18. TvTagCloud
      19. Wayfinder
        1. Examples
      20. Weblogin
      21. WebLoginPE
        1. API
        2. Parameters
        3. Placeholders
        4. Typical Errors
        5. Views (Templates)
        6. Working with Forms
      22. YAMS
        1. Configuration
        2. How To
          1. YAMS + Breadcrumbs
          2. YAMS + Ditto
          3. YAMS + Ditto + PHx
          4. YAMS + eForm
          5. YAMS + Jot
          6. YAMS + Snippets
          7. YAMS + Wayfinder
          8. YAMS Custom Multilingual TVs, Chunks, Snippets
          9. YAMS Language Dependent Layout
          10. YAMS Language Flag List
          11. YAMS Language Select Landing Page
          12. YAMS Mime-type Dependent Alias Suffixes
          13. YAMS Multilingual Weblinks
          14. YAMS XML Sitemap
        3. Installation
        4. Language Modes
        5. Language Settings
        6. Placeholders
        7. Setup
        8. Snippet
        9. Technical Details
    3. Evo Tutorials
      1. Extras - How To
        1. Ditto Tutorials
          1. Add Ditto Pagination
          2. Basic RSS feed
          3. Category Tagging with Ditto
          4. Create a Custom Ditto Template
          5. Custom Placeholders
          6. Dropdown Menu with Ditto
          7. Dynamically Show Related Posts
          8. Promote to Home Page
          9. Sort by a date tv
          10. Tagged blogging with Ditto (ex.1)
          11. Tagged blogging with Ditto (ex.2)
          12. Tagging Screencast

Custom Modifiers

This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.

Installation

  1. Login to the Evo admin interface
  2. Go to Resources => Manage Resources => Snippets
  3. Click "new snippet"
  4. Prefix the snippet name with "phx:"
  5. Copy the code to that new snippet and save it

or

  1. Create new file with "snippet.phx.php" in assets/plugins/phx/modifiers/ (Example: assets/plugins/phx/modifiers/phpthumb.phx.php)
  2. Copy the code to that new file, and here you go!
  3. Change the permissions to 0644 to your new file

Contributed

phx:7bit

  • description: returns the 7bit representation of a string
  • usage: [string:7bit]
<?php
$text = mb_convert_encoding($output,'HTML-ENTITIES',mb_detect_encoding($output));
$text = preg_replace(array('/&szlig;/','/&(..)lig;/','/&([aouAOU])uml;/','/&(.)[^;]*;/'),array('ss',"$1","$1".'e',"$1"),$text);
return $text;
?>

phx:age

  • description: Takes a unixtime date input and calculates the age in years. It kind of fakes leap years but it's probably close enough for most uses.
  • example: Set a TV called "date_birth" with the unixtime widget, then output it as [date_birth:age]
  • usage: [date_birth:age]
  • added by: themancan
<?php
$output = floor((time() - $output) / 31557600);
return $output;
?>

phx:alternateClass

  • description: Allows rows or other repeating elements to alternate provided the $output is an integer generated by a loop.
  • usage: [phx:alternateClass=`class name`]
  • example: <li class="[maxigallery.picture.pos:alternativeClass=`alt`]"> outputs <li class="alt"> for every other <li> in the loop.
  • notes: Originally designed for use with MaxiGallery to apply an alternating class to the <li> galleryPictureTpl template chunk.
  • added by: smashingred
<?php
if($output % 2)
{
echo $options;
}else{
echo '';
}
?>

phx:bbcode

  • description: parse bb code (also escapes all html and Evo tags characters)
  • usage: [variable:bbcode]
<?php
$string = preg_replace("/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", htmlspecialchars($output));
$string = preg_replace('~\[b\](.+?)\[/b\]~is', '<b>\1</b>', $string);
$string = preg_replace('~\[i\](.+?)\[/i\]~is', '<i>\1</i>', $string);
$string = preg_replace('~\[u\](.+?)\[/u\]~is', '<span style="text-decoration: underline;">\1</span>', $string);
$string = preg_replace('~\[link\]www.(.+?)\[/link\]~is', '<a href="http://www.\1" target="_blank">www.\1</a>', $string);
$string = preg_replace('~\[link\](.+?)\[/link\]~is', '<a href="\1" target="_blank">\1</a>', $string);
$string = preg_replace('~\[link=(.+?)\](.+?)\[/link\]~is', '<a href="\1" target="_blank">\2</a>', $string);
$string = preg_replace('~\[url\]www.(.+?)\[/url\]~is', '<a href="http://www.\1" target="_blank">www.\1</a>', $string);
$string = preg_replace('~\[url\](.+?)\[/url\]~is', '<a href="\1" target="_blank">\1</a>', $string);
$string = preg_replace('~\[url=(.+?)\](.+?)\[/url\]~is', '<a href="\1" target="_blank">\2</a>', $string);
$string = preg_replace('~\[img\](.+?)\[/img\]~is', '<img src="\1" alt="[image]" style="margin: 5px 0px 5px 0px" />', $string);
$string = preg_replace('~\[img-l\](.+?)\[/img\]~is', '<img src="\1" alt="[image]" style="border: thin solid #DFE5F2; FLOAT: left; MARGIN-RIGHT: 20px" />', $string);
$string = preg_replace('~\[img-r\](.+?)\[/img\]~is', '<img src="\1" alt="[image]" style="border: thin solid #DFE5F2; FLOAT: right; MARGIN-LEFT: 20px;" />', $string);
$string = preg_replace('~\[color=(.+?)\](.+?)\[/color\]~is', '<font color="\1">\2</font>', $string);
$string = preg_replace('~\[left\](.+?)\[/left\]~is', '<div style="text-align:left;">\1</u>', $string);
$string = preg_replace('~\[center\](.+?)\[/center\]~is', '<div style="text-align:center;">\1</u>', $string);
$string = preg_replace('~\[right\](.+?)\[/right\]~is', '<div style="text-align:right;">\1</u>', $string);

$string = str_replace(array("[","]","`"),array("&#91;","&#93;","&#96;"),$string);

return $string;
?>

phx:cdata

  • description: Surround content with CDATA without the whitespace
  • usage: [content:cdata]
  • added by: Hori
<?php
if (!function_exists('cdata')){
function cdata($inhoud){
$before='<![CDATA[';
$after=']]>';
return $before.$inhoud.$after;
}
}
return cdata($output);
?>

phx:character_limit

  • description: limits content to specified number of characters (good for news summary)
  • usage: [+content:character_limit=`35`+] - limits characters to 35
  • added by: themancan
<?php
$output_truncated = substr($output, 0, $options);
return $output_truncated;
?>
  • Improved version by prouve
<?php
if (strlen($output) > $options) {
$output_cutted = substr($output, 0, $options);
$last_space = strrpos($output_cutted, " ");
$output = substr($output_cutted, 0, $last_space) . " […]";
}
return $output;
?>

phx:checkdomainexists

  • description: See if a domain is avaliable or not, it acts with Conditional operators.
  • usages:
  • [phx:checkdomainexists=`www.mydomain.com`:then=`it exists!`:else=`Houston, we've got a problem!`]
  • [phx:checkdomainexists=`[+phx:post=`domain`]`:then=`it exists!`:else=`Houston, we've got a problem!`+]
  • added by: CuSS
<?php
/*
// checkdomainexists - Phx Script Created by José Moreira
// Based on: AJAX Domain Availablity Check script (Version 0.93) - Created by "Ganesh" @ http://www.bootstrike.com/Webdesign/
// Give him an applause!
*/

/****************************************************
Usage: isDomainAvailable(domain,domaintlds)
Examples:
isDomainAvailable("www.domain.com") //to allow all tlds
isDomainAvailable("www.domain.com", array('com','net','org')); // to allow only com, net and org domains.
isDomainAvailable("www.domain.com", array('com.sg')); // to allow only com.sg domain checking
****************************************************/
function isDomainAvailable($domain,$allowedTLDs=null){
global $error;
/* data from dnservers.php */
$ext = array(
// '.EXT' => array('WHOIS SERVER NAME','Text To Match for Available Domain'),
'.com' => array('whois.crsnic.net','No match for'),
'.net' => array('whois.crsnic.net','No match for'),
'.org' => array('whois.publicinterestregistry.net','NOT FOUND'),
'.us' => array('whois.nic.us','Not Found'),
'.biz' => array('whois.biz','Not found'),
'.info' => array('whois.afilias.net','NOT FOUND'),
'.mobi' => array('whois.dotmobiregistry.net', 'NOT FOUND'),
'.tv' => array('whois.nic.tv', 'No match for'),
'.in' => array('whois.inregistry.net', 'NOT FOUND'),
'.co.uk' => array('whois.nic.uk','No match'),
'.co.ug' => array('wawa.eahd.or.ug','No entries found'),
'.or.ug' => array('wawa.eahd.or.ug','No entries found'),
'.sg' => array('whois.nic.net.sg','Domain Not Found'),
'.com.sg' => array('whois.nic.net.sg','Domain Not Found'),
'.per.sg' => array('whois.nic.net.sg','Domain Not Found'),
'.org.sg' => array('whois.nic.net.sg','Domain Not Found'),
'.com.my' => array('whois.mynic.net.my','does not Exist in database'),
'.net.my' => array('whois.mynic.net.my','does not Exist in database'),
'.org.my' => array('whois.mynic.net.my','does not Exist in database'),
'.edu.my' => array('whois.mynic.net.my','does not Exist in database'),
'.my' => array('whois.mynic.net.my','does not Exist in database'),
'.nl' => array('whois.domain-registry.nl','not a registered domain'),
'.ro' => array('whois.rotld.ro','No entries found for the selected'),
'.com.au' => array('whois-check.ausregistry.net.au',"Available\n"),
'.net.au' => array('whois-check.ausregistry.net.au',"Available\n"),
'.ca' => array('whois.cira.ca', 'AVAIL'),
'.org.uk' => array('whois.nic.uk','No match'),
'.name' => array('whois.nic.name','No match'),
'.ac.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ne.ug' => array('wawa.eahd.or.ug','No entries found'),
'.sc.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ws' => array('whois.website.ws','No Match'),
'.be' => array('whois.ripe.net','No entries'),
'.com.cn' => array('whois.cnnic.cn','no matching record'),
'.net.cn' => array('whois.cnnic.cn','no matching record'),
'.org.cn' => array('whois.cnnic.cn','no matching record'),
'.no' => array('whois.norid.no','no matches'),
'.se' => array('whois.nic-se.se','No data found'),
'.nu' => array('whois.nic.nu','NO MATCH for'),
'.com.tw' => array('whois.twnic.net','No such Domain Name'),
'.net.tw' => array('whois.twnic.net','No such Domain Name'),
'.org.tw' => array('whois.twnic.net','No such Domain Name'),
'.cc' => array('whois.nic.cc','No match'),
'.nl' => array('whois.domain-registry.nl','is free'),
'.pl' => array('whois.dns.pl','No information about'),
'.eu' => array('whois.eu','Status: AVAILABLE'),
'.pt' => array('whois.dns.pt','No match'),
'.se' => array('whois.iis.se','not found'), //contributed by Mr. Roger xxx@tving.se
);

$R6629C5988EEFCD88EA6F77A2AE672B96 = trim($domain); if (preg_match('/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$/i',$R6629C5988EEFCD88EA6F77A2AE672B96) != 1) { $error = 'Invalid domain (Letters, numbers and hypens only) ('.$R6629C5988EEFCD88EA6F77A2AE672B96.')'; return false; } preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $R6629C5988EEFCD88EA6F77A2AE672B96, $R2BC3A0F3554F7C295CD3CC4A57492121); $RE035DC327C1676D83C2CA9CA79C74BCB = ''; $R6629C5988EEFCD88EA6F77A2AE672B96 = $R2BC3A0F3554F7C295CD3CC4A57492121[2]; $R37D331C368B44BDD85AF95D9FFFFD202 = explode('.', $R6629C5988EEFCD88EA6F77A2AE672B96); $R33D3EC748433467E20D0947C3032E305 = ''; if (count($R37D331C368B44BDD85AF95D9FFFFD202) == 3) { $R33D3EC748433467E20D0947C3032E305 = strtolower($R37D331C368B44BDD85AF95D9FFFFD202[1].'.'.$R37D331C368B44BDD85AF95D9FFFFD202[2]); } else if (count($R37D331C368B44BDD85AF95D9FFFFD202) == 2) { $R33D3EC748433467E20D0947C3032E305 = strtolower($R37D331C368B44BDD85AF95D9FFFFD202[1]); } else { $error = 'Invalid Domain and/or TLD server entry does not exist'; return false; } if ($allowedTLDs != null) { $R630663E4CF314AFD500B9B8E1AA95DF0 = count($allowedTLDs); $RDBF866E6293BB59E654033E299EC8CFE = false; for ($RA16D2280393CE6A2A5428A4A8D09E354 = 0; $RA16D2280393CE6A2A5428A4A8D09E354 < $R630663E4CF314AFD500B9B8E1AA95DF0; $RA16D2280393CE6A2A5428A4A8D09E354++) { if ($allowedTLDs[$RA16D2280393CE6A2A5428A4A8D09E354] === $R33D3EC748433467E20D0947C3032E305) { $RDBF866E6293BB59E654033E299EC8CFE = true; break; } } if (!$RDBF866E6293BB59E654033E299EC8CFE) { $error = 'TLD '.$R33D3EC748433467E20D0947C3032E305.' not allowed'; return false; } } $R019FB4DA0E10A95A57615147DF79F334 = false; if (!array_key_exists('.'.$R33D3EC748433467E20D0947C3032E305, $ext)) { $R019FB4DA0E10A95A57615147DF79F334 = true; } $RE22CBD8984E1727D0A587413D72A88CF = gethostbyname ($R6629C5988EEFCD88EA6F77A2AE672B96); if (($RE22CBD8984E1727D0A587413D72A88CF != $R6629C5988EEFCD88EA6F77A2AE672B96) && ($RE22CBD8984E1727D0A587413D72A88CF != '208.67.219.132')) { return false; } else { $server = ''; if ($R019FB4DA0E10A95A57615147DF79F334) { $RBD7EDCF7DA1CE9EA93A9B3BBD829FFBB = explode('.',$R33D3EC748433467E20D0947C3032E305); if (count($RBD7EDCF7DA1CE9EA93A9B3BBD829FFBB) > 1) $server = $RBD7EDCF7DA1CE9EA93A9B3BBD829FFBB[1].'.whois-servers.net'; else $server = $R33D3EC748433467E20D0947C3032E305.'.whois-servers.net'; $R7B8A9F2F48B874D40BD75BDD12F02557 = @gethostbyname($R33D3EC748433467E20D0947C3032E305.'.whois-servers.net'); } else { $server = $ext['.' .$R33D3EC748433467E20D0947C3032E305][0]; $R7B8A9F2F48B874D40BD75BDD12F02557 = @gethostbyname($server); } if ($R33D3EC748433467E20D0947C3032E305 == 'es') { $error = 'Error: ES not supported. They don\'t have a public whois server :('; return false; } if ($R33D3EC748433467E20D0947C3032E305 == 'au') { $server = $ext['.com.au'][0]; $R7B8A9F2F48B874D40BD75BDD12F02557 = @gethostbyname($server); } if ($R7B8A9F2F48B874D40BD75BDD12F02557 == $server) { $error = 'Error: Invalid extension - '.$R33D3EC748433467E20D0947C3032E305.'. Or server has outgoing connections blocked to '.$server.'. Domain does not have DNS entry, so chances are high it is available.'; return false; } $RAD10634E7F72CAA071320F21AEE5930D = @fsockopen($server, 43,$R32D00070D4FFBCCE2FC669BBA812D4C2,$RE5840D3E86DCF8489051E4F70C757552,10); if ($R32D00070D4FFBCCE2FC669BBA812D4C2 == '10060') { $error = 'Error: Invalid extension - '.$R33D3EC748433467E20D0947C3032E305.' (or whois server is down). Domain does not have DNS entry, so chances are high it is available.'; return false; } if (!$RAD10634E7F72CAA071320F21AEE5930D || ($RE5840D3E86DCF8489051E4F70C757552 != '')) { $error = 'Error: ('.$server.') '.$RE5840D3E86DCF8489051E4F70C757552.' ('.$R32D00070D4FFBCCE2FC669BBA812D4C2.')'; return false; } fputs($RAD10634E7F72CAA071320F21AEE5930D, "$R6629C5988EEFCD88EA6F77A2AE672B96\r\n"); while( !feof($RAD10634E7F72CAA071320F21AEE5930D) ) { $RE035DC327C1676D83C2CA9CA79C74BCB .= fgets($RAD10634E7F72CAA071320F21AEE5930D,128); } fclose($RAD10634E7F72CAA071320F21AEE5930D); if($R33D3EC748433467E20D0947C3032E305 == 'org') nl2br($RE035DC327C1676D83C2CA9CA79C74BCB); if ($R019FB4DA0E10A95A57615147DF79F334) { if ( (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No match for') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'NOT Found') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'NOT FOUND') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'Not found: ') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,"No Found\n") !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'NOMATCH') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,"AVAIL\n") !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No entries found') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'NO MATCH') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No match') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No such Domain') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'is free') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'FREE') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No data Found') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No Data Found') !== false) || ($RE035DC327C1676D83C2CA9CA79C74BCB == "Available\n") || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'No information about') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'no matching record') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'does not Exist in database') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'Status: AVAILABLE') !== false) || (strpos($RE035DC327C1676D83C2CA9CA79C74BCB,'not a registered domain') !== false) ) { return true; } return false; } else { if ((strpos($R33D3EC748433467E20D0947C3032E305,'.au') > 0) && ($RE035DC327C1676D83C2CA9CA79C74BCB == "Not Available\n")) { return false; } if(preg_match('/'.$ext['.' . $R33D3EC748433467E20D0947C3032E305][1].'/i', $RE035DC327C1676D83C2CA9CA79C74BCB)) { return true; } else { return false; } } } return false;
}
// echo $error;
$condition[] = intval(!isDomainAvailable($options));
?>

phx:docfield

  • description: get specified field from document (id)
  • usage: [+docid:docfield=`field`+]
  • defaults to pagetitle
  • added by: bwente
<?php
$field = (strlen($options)>0) ? $options : 'pagetitle';
$docfield = $modx->getTemplateVarOutput(array($field), $output, 1);
return $docfield[$field];
?>

phx:domainhasmail

  • description: See if a domain has a mail server or not, it acts with Conditional operators.
  • IMPORTANT: It uses exec() function, make sure you have it enabled on your php.ini!
  • usages:
  • [+phx:domainhasmail=`www.mydomain.com`:then=`it has mail!`:else=`Oh no!`+]
  • [+phx:domainhasmail=`[phx:post=`domain`+]`:then=`it has mail!`:else=`Oh no!`]
  • added by: CuSS
<?php
function checkdnsmail($a,$b=''){if(!empty($a)){if($b=='') $b="A";exec("nslookup -type=$b $a",$c);foreach($c as $d){if(eregi("^$a",$d)) return true;}return false;}return false;}
$condition[] = intval(checkdnsmail($options));
?>

phx:evenodd

  • description: Returns even if even, otherwise odd. Nearly identical to the 'alternateClass' above.
  • usage: [+ditto_iteration:evenodd+]. Useful for creating alternate templates in Ditto without needing an additional chunk. For example, class="news_item_[+ditto_iteration:evenodd+]" will return news_item_even or news_item_odd
  • default: Defaults to "odd", as there is no test to ensure the input is an integer.
  • added by: themancan
<?php
if ($output % 2) {
return 'even';
} else {
return 'odd';
}
?>

phx:fileexists

  • description: See if a file exists or not, it acts with Conditional operators. Useful for autodetect images on chunks, and replace broken images by an blank image. You can use it to show products images automaticly by using [id] or something on your image name.
  • usages:
  • [+phx:if=`assets/images/path/to/your/file.jpg`:fileexists:then=`Hey, the file exists!`:else=`Oh no! Where is the file?`+]
  • [+myimage:fileexists:then=`Hey, the file exists!`:else=`Oh no! Where is the file?`+]
  • <img src="[+myimage:fileexists:then=`[myimage:phpthumb=`w=200`+]`:else=`[+phx:input=`path/to/blank/image.jpg`:phpthumb=`w=200`+]`]" alt="">
  • added by: CuSS
<?php
$condition[] = intval(file_exists($output));
?>

phx:firstlast

  • description: Set the number of elements per row. Returns $class_first if it's the first element in a row; $class_last if it's the last.
  • usage: [+ditto_iteration:firstlast=`4`+]. Useful for applying classes to the first or last element per row. Kind of like alternate classes, but suited for multiple rows.
<?php
if (!$options) {
$options = 2;
}
$class_first = 'alpha';
$class_last = 'omega';

if (($output % $options) == '0') {
return $class_first;
} elseif (($output % $options) == ($options - 1)) {
return $class_last;
} else {
return;
}
?>

phx:genitive

  • description: Creates the genitive of a name - appends either ?s or ?
  • usage: [+myname:genitive+] or [+myname:genitive=`endchar|normalchar|otherchar`+]
  • added by: maFF
<?php
/**
* Creates the genitive of a name.
*
* Examples:
* Joe => Joe's
* Mary => Mary's
* Lucas => Lucas'
*
* Usage:
*
* [+myname:genitive+]
* [+myname:genitive=`endchar|normalchar|otherchar`+]
*
*/

$options = explode('|', $options);
$name = $output;

$endchar = (!empty($options[0])) ? $options[0] : 's'; // char a name has to end with to get treated specially
$normalchar = (!empty($options[1])) ? $options[1] : '&prime;s'; // char to append to 'normal' names
$otherchar = (!empty($options[2])) ? $options[2] : '&prime;'; // char to append to names which end with $endchar

if(substr($name, -1) == $endchar) $genitive = $name.$otherchar;
else $genitive = $name.$normalchar;

return $genitive;
?>

phx:get

  • description: get value by name from superglobal $_GET array
  • usage: [phx:get=`name`]
<?php
return htmlspecialchars($_GET[$options]);
?>

phx:gettype

  • description: See the type of the result, usefull to make mathematical operations like avaliate a number to see if it is multiple of another or to use as security, to get a var from POST and GET and see if it is a number.
  • usages:
  • [+counter:math=`?/4`:gettype:is=`integer`:then=`This number is multiple of four!`+]
  • [+phx:post=`mobilephone`:gettype:ne=`integer`then=`this var contains non-numeric chars`+]
  • added by: CuSS
<?php
function gettype_fromstring($string){
// (c) José Moreira - Microdual
return gettype(getcorrectvariable($string));
}
function getcorrectvariable($string){
// (c) José Moreira - Microdual
// With the help of Svisstack (http://stackoverflow.com/users/283564/svisstack)
/* FUNCTION FLOW */
// *1. Remove unused spaces
// *2. Check if it is empty, if yes, return blank string
// *3. Check if it is numeric
// *4. If numeric, this may be a integer or double, must compare this values.
// *5. If string, try parse to bool.
// *6. If not, this is string.
$string=trim($string);
if(empty($string)) return "";
if(!preg_match("/[^0-9.]+/",$string)){
if(preg_match("/[.]+/",$string)){
return (double)$string;
}else{
return (int)$string;
}
}
if($string=="true") return true;
if($string=="false") return false;
return (string)$string;
}
return gettype_fromstring($output);
?>

phx:grabsrcurl

  • description: gets the contents of the src attribute of an element. For example, if applied to <img src="test.png" alt=""> it will return test.png.
  • usage: [+string:grabsrcurl+] or, more usefully, [*TV:grabsrcurl*]
<?php
return preg_replace('/.*src=([\'"])((?:(?!\1).)*)\1.*/si','$2',$output);
?>

phx:has

  • description: See if the output string has the option (like 'is' but not equal - 'has'). This is needed if the return is an array (multiple selects from TV) or a big string.
  • usages:
  • [+myMultipleTemplateVariable:has=`one-of-the-strings`:then=`it has!`:else=`Oh no, you didn't select it!`+]
  • added by: CuSS
<?php
$condition[] = intval(strpos($output,$options)!==false);
?>

phx:ifnotempty

  • description: The opposite of the native PHX "ifempty" function. Returns the option value ONLY if the input value is empty (excluding whitespace)
  • usage: [+phx:if=`string`:ifnotempty=`String to return if not empty`+]
<?php
if (trim($output) != '') {
return $options;
}
?>

phx:isempty

  • description: The opposite of the native PHX "ifempty" function, like ifnotempty, but it returns true or false to then and else operators
  • usage:
  • [+phx:if=`string`:isempty:then=`String to return if empty`+]
  • [+myplaceholder:isempty:then=`String to return if empty`+]
  • added: CuSS
<?php
$condition[] = intval(trim($output) == '');
?>

phx:isnotempty

  • description: The opposite of "isempty" function, it returns true or false to then and else operators.
  • usage:
  • [+phx:if=`string`:isnotempty:then=`String to return if not empty`+]
  • [+myplaceholder:isnotempty:then=`String to return if not empty`+]
  • added: CuSS
<?php
$condition[] = intval(trim($output) != '');
?>

phx:loggedinmgr

  • usage: [+phx:loggedinmgr:then=`loggedInString`:else=`notLoggedInString`+]
  • modded: CuSS
<?php
global $modx;
$condition[] = intval(isset ($_SESSION['mgrValidated']));
?>

phx:loggedinweb

  • usage: [+phx:loggedinweb:then=`loggedInString`:else=`notLoggedInString`+]
  • added: CuSS
<?php
global $modx;
$condition[] = intval(isset ($_SESSION['webValidated']));
?>

phx:make_url

  • description: Takes a string and makes it a URL if it's not.
  • example: If a user enters 'www.example.com', but you want to link to that, if you did 'href="www.example.com"' it wouldn't work. Yeah, you should be validating that on the server side anyway, but this modifier is useful in case you can't. It will make "www.example.com" into "http://www.example.com", but won't touch things that start with an http:// or https://
  • usage: [member_url:make_url]
  • default: Adds "http://" to the beginning of the string.
  • added by: themancan
<?php
if (preg_match('%https?://%i', $output)) {
return $output;
} else {
return 'http://' . $output;
}
?>

phx:mydate

  • description: Date modified for non-Unix timestamp dates.
  • example: Useful when the date is stored differently, e.g. Friday, May 12, 2008 etc.
  • usage: [date:mydate=`%d-%m-%Y %H:%M`]
  • added by Legatissima who found it in the support forum, written by Doze
<?php
return strftime($options, strtotime($output));
?>

phx:nohttp

  • description: Removes the http:// from a URL, to create a display-friendly web address
  • usage: [+string:nohttp+]
<?php
$url = str_replace('http://', '', $output);
return $url;
?>

phx:ordinal

  • description: Ordinal numbers.
  • usage: *[number:ordinal]*
  • notes: Adds 'st' to 21 to make it the 21st or 'nd' to 132 for 132nd.
  • added by: bwente
<?php
if (!function_exists('ordinal'))
{
function ordinal($cardinal){
$test_c = abs($cardinal) % 10;
$ext = ((abs($cardinal) %100 < 21 && abs($cardinal) %100 > 4) ? 'th'
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)
? 'th' : 'st' : 'nd' : 'rd' : 'th'));
return $cardinal.$ext;
}
}
return ordinal($output);
?>

phx:outer

  • description: Surround not empty string with text.
  • usage: [string:outer=`before|after`]
  • example: [+phx:input=`[!Ditto? &noResults=``!]`:outer=`<div class="xyz">|</div>`+]
  • added by: Jako
<?php
$options = explode("|", $options);
$outer = '';
if (trim($output) != '') $outer = $options[0].$output.$options[1];
return $outer;
?>

phx:parent

  • description: get specified document field from parent document (id)
  • usage: [+variable:parent=`field`+]
  • defaults to pagetitle
<?php
$field = (strlen($options)>0) ? $options : 'pagetitle';
$parent = $modx->getParent($output,1,$field);
return $parent[$field];
?>

phx:parseLinks

  • usage: [+placeholder:parseLinks+]
<?php
/*
* phx:parseLinks
*/
$t = $output;
$t = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "<a href=\"\\0\">\\0</a>", $t);
$t = ereg_replace("(^| |\n)(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a href=\"http://\\2\">\\2</a>", $t);
return $t;
?>

phx:phpthumb

  • description: uses phpThumb to resize images
  • usage: [+myimage+] contains the full path to the image
  • [myimage:phpthumb=`w=450`]
  • [myimage:phpthumb=`w=450&ar=x&fltr{}=gray&fltr{}=rcd|8|1`]
  • [myimage] contains only the filename
  • [myimage:phpthumb=`w=450#[(base_path)]assets/images/`]
  • [myimage] contains no data referring to the image
  • [myimage:phpthumb=`w=450#[(base_path)]assets/images/myimage.jpg#1`]

phx:phone

  • description: transform human readable number ex. +1 (234) 567-89-10 into machine form ex. +12345678910 (remove " ", "(", ")", "-")
  • usage: [phx:input=`phone number`:phone]
  • installation: create snippet named phx:phone and paste code by: Aramaki
<?php
return str_replace( array ("(", ")", "-", " "), "", $output );
?>

phx:post

  • description: get value by name from superglobal $_POST array
  • usage: [+phx:post=`name`+]
<?php
return htmlspecialchars($_POST[$options]);
?>

phx:price_format

  • description: Formats a number (TV) to a specific format with a specific number of decimals. Useful for allowing users to enter a "price" TV, and making sure you have a consistent XX.YY format, even if they just enter XX.
  • usage: [+product_price:price_format+].
  • default: Defaults to 2 decimal places.
  • added by: themancan
<?php
if (!function_exists(format_number)) {
function format_number($str,$decimal_places='2',$decimal_padding="0"){
/* taken from http://us2.php.net/manual/en/function.number-format.php#54799 */
/* firstly format number and shorten any extra decimal places */
/* Note this will round off the number pre-format $str if you dont want this fucntionality */
$str = number_format($str,$decimal_places,'.',''); // will return 12345.67
$number = explode('.',$str);
$number[1] = (isset($number[1]))?$number[1]:''; // to fix the PHP Notice error if str does not contain a decimal placing.
$decimal = str_pad($number[1],$decimal_places,$decimal_padding);
return (float) $number[0].'.'.$decimal;
}
}
return format_number($output);
?>

phx:rating

  • description: user rating system based on Jot post count
  • usage: [+comment.userpostcount:rating+]
<?php
$defaultValue = " <img src=assets/images/icons/star.png />";
if (intval($output) <= '1') {
$newvalue = '<img src=assets/images/icons/bronze.png />';
}
elseif (intval($output) <= '2') {
$newvalue = '<img src=assets/images/icons/silver.png />';
}
elseif (intval($output) <= '3') {
$newvalue = '<img src=assets/images/icons/gold.png />';
}
else {
$newvalue = $defaultValue;
}
return $newvalue;
?>

phx:request

  • description: get value by name from superglobal $_REQUEST array
  • usage: [+phx:request=`name`+]
<?php
return htmlspecialchars($_REQUEST[$options]);
?>

phx:return_domain

  • description: Takes a string and returns the domain.
  • example: "http://wiki.domain.com/index.php?title=PHx/CustomModifiers&action=edit" would return just 'wiki.domain.com'.
  • note: This is designed to be used on a Evo TV with an Input Type of 'URL'. It doesn't do any sort of error checking.
  • usage: [url:return_domain].
  • added by: themancan
<?php
preg_match('%(?:https?://)?(?:www\.)?([^/]*)%i', $output, $matches);
return $matches[1];
?>

phx:smileys

  • description: Converts text patterns into smiley images.
  • usage: *[content:smileys]*
  • notes: it works with the silk iconset by famfamfam out of the box, if you put the icons into assets/images/smileys. If you want to use other smileys/replacement tags just edit the smileys array.
  • added by: maFF
<?php
$smiley_basepath = $modx->config['base_url'].'assets/images/smileys/';
$smiley_imagetag = '<img src="'.$smiley_basepath.'##smiley##" alt="##text##" title="##text##" />';

$smileys = array(
':grin:' => array( // replace pattern
'emoticon_evilgrin.png', // file name
':D'), // text version for alt and title tags
':smile:' => array(
'emoticon_happy.png',
':)'),
':sad:' => array(
'emoticon_unhappy.png',
':('),
':wink:' => array(
'emoticon_wink.png',
';)'),
':tongue:' => array(
'emoticon_tongue.png',
':P'),
':surprised:' => array(
'emoticon_surprised.png',
':O')
);

foreach($smileys as $search => $smiley) {
$thistag = $smiley_imagetag;
$thistag = str_replace('##smiley##', $smiley[0], $thistag);
$thistag = str_replace('##text##', $smiley[1], $thistag);
$output = str_replace($search, $thistag, $output);
}
return $output;
?>

phx:stripsnippet

  • description: Removes cached and uncached snippet in output (usefull in Ditto summarize)
  • usage: [+string:stripsnippet+]
<?php
$string=$output;
$string = preg_replace('~\[\[[^\]]*\]\]~is', '', $string);
$string = preg_replace('~\[\![^!]*\!\]~is', '', $string);
return $string;
?>

phx:stripparams

  • description: Strips all parameters from an URL, e.g. example.com/page.html?foo=bar&baz=foo becomes example.com/page.html
  • usage: [url:stripparams]
  • added by: maff
<?php
$pos = strpos($output, '?');
if($pos !== false) {
$output = substr($output, 0, $pos);
}

return $output;
?>

phx:striptags

  • description: Strips all HTML and PHP tags. You can use the optional parameter to specify tags which should _not_ be stripped
  • usage: [comment.content:striptags=`<a><img>`]
<?php
return($modx->stripTags($output, $options));
?>

phx:thumb

  • description: Similar to maFF's phx:phpthumb but just uses a standard phpThumb installation. Requires phpThumb. I'm adding this in addition to the version above because options are always good, and this method just uses an unmodified version of phpThumb. (It also doesn't use the hashing that maFF's version does, so if you need that, use the above version.)
  • usage: (basically the same as maFF's version)
    [myimage] contains the full path to the image
    [myimage:phpthumb=`w=450`]
    [myimage:phpthumb=`w=450&ar=x&fltr{}=gray&fltr{}=rcd|8|1`]
  • installation: change the path in the code to wherever you like to put your phpThumb. Make sure you make phpThumb's cache directory writable and set phpThumb's config file to how you want it by: themancan
<?php
$output = '/assets/snippets/thumb/phpThumb.php?src=' . $output . $options;
return $output;
?>

phx:timesince

  • description: Converts a unix timestamp into the number of years, months, days, hours, minutes, and optionally seconds from the current time.
  • usage: [+date:timesince+]
  • added by: apoxx
<?php
if (!function_exists('timeSince'))
{
function timeSince($timestamp)
{
if ($timestamp >= time())
{
$timeago = '0 seconds ago.';
return $timeago;
}
$seconds = time()-$timestamp;
$units = array(
'year' => 31556926,
'month' => 2629743,
'day' => 86400,
'hour' => 3600,
'minute' => 60,
// 'second' => 1
);
$timeago = '';
foreach ($units as $key => $val)
{
if ($seconds >= $val)
{
$results = floor($seconds/$val);
$seconds = ($seconds-($results*$val));
$timeago .= ($results >= 2) ? $results . ' ' . $key . 's, ' : $results . ' ' . $key . ', ';
}
}
return rtrim($timeago, ', ') . ' ago';
}
}
return timeSince($output);
?>

phx:time

  • description: Returns Unix timestamp time().
  • usage: [+phx:time:date=`%Y`+] // Gives the Now Year
  • added: CuSS
<?php
return time();
?>

phx:tv

  • description: get a template variable from any page id
  • usage: [+phx:tv=`<docid>?<templatevar>`+], where <docid> is the document id (e.g. 25) and <templatevar> is a template variable associated to the given docid.
  • default: if the document id or the template variable don't exist no output is produced
  • added by: natalino
<?php
if(strlen($options )>0) {
$data = explode("?",trim($options),2);
$id= (!empty($data[0]) && is_numeric($data[0])) ? $data[0]: '';
$tv= (!empty($data[1])) ? $data[1]: '';
$result = $modx->getTemplateVar($tv, 'name', $id, 1);
return $result['value'];
}
?>

phx:uri

  • description: takes a string and prepares it to be a part of a valid URI.
  • usage: [+string:uri+]
<?php
return rawurlencode($output);
?>

phx:url

  • description: takes a document id and creates the corresponding Evo link (similar to [~10~])
  • usage: *[id:url]*
<?php
return $modx->makeUrl($output);
?>

phx:word_limit

  • description: limits content to specified number of words (good for news summary)
  • usage: [+content:word_limit=`10`+] - limits content to 10 words
  • added by: yentsun
<?php
$retval = $output;
$array = explode(" ", $output);
if (count($array)<=$options)
{
$retval = $output;
}
else
{
array_splice($array,$options);
$retval = implode(" ", $array);
}
return $retval;
?>

phx:zeropad

  • description: Zero-padding a string. Takes the number of total digits as the input.
  • example: This can be useful when you want to output some kind of ID numbers with fixed digits, or US zip codes: "00001", "00124", "90210"
  • usage: [ditto_iteration:zeropad=`3`] [zipcode:zeropad=`5`]
  • default: No zero-padding.
  • added by: ryanlwh
<?
return sprintf("%0".$options."s",$output);
?>

Suggest an edit to this page.