Sunday, September 26, 2010

modx2 getResources vs ditto

Modx2 uses getResources + getPage to replace ditto snippet from Modx1.
Syntax wise, there are similarity but slightly different in usage.

ditto: display=`20`,
modx2: getResources &limit=`20`

ditto: &paginate=`1`,
modx2: getPage &pageVarKey=`page` &element=`getResources` &elementClass=`modSnippet`

ditto: &extenders=`summary,dateFilter`&dateFormat=`%b %d, %Y` &sortBy=`pub_date` &sortDir=`DESC` &dateSource=`pub_date`
modx2: &sortby=`publishedon` &sortdir=`desc`&sortby=`publishedon` &sortdir=`desc`

ditto chunk: [+date+], [+summary+]
modx2: [[+publishedon:strtotime:date=`%b %d, %Y`]], [[+introtext:empty=`[[+content:ellipsis=`250`:striptags]]`]]

And some additional parameter not set default by modx2 getResources:
&showHidden=`1` &includeContent=`1`

And display page number:
[[!+page.nav:notempty=`
    [[!+page.nav]]
    `]]

    For reference:
    http://rtfm.modx.com/display/ADDON/getResources


    Example:
    [[!getPage? &limit=`20` &parents=`4733` &showHidden=`1`&sortby=`publishedon` &sortdir=`desc` &pageVarKey=`page`&element=`getResources` &elementClass=`modSnippet` &tpl=`ditto_investoraudit_summary2` &sortby=`publishedon` &sortdir=`desc` &includeContent=`1`]]

    [[!+page.nav:notempty=`
    <div class="paging">
    <ul class="pageList">
    [[!+page.nav]]
    </ul>
    </div>
    `]]

    Wednesday, August 25, 2010

    PHP Big Bummer!

    When a string is set to empty String "":
    --------------
    $myvar = "";
    echo is_null($myvar) ? "is null" : "not null";
    //return not null
    echo $myvar==null ? "is null" : "not null";
    //return IS NULL
    //whattttt????
    =========
    When a array is set to empty String "":
    $myvar = array("myname" => "");
    echo is_null($myvar["myname"]) ? "is null" : "not null";
    //return not null
    echo isset($myvar["myname"]) ? "is set" : "not Set";
    //return NOT SET!
    //whatttttt????
    echo $myvar["myname"] == null ? "is null" : "not null";
    //return IS NULL!
    //what??????????

    Thursday, August 19, 2010

    Modx 1.04 Event Sequence

    List of events in sequence
    - OnBeforeManagerPageInit (DocumentParser::getSettings), if is manager
    - OnWebPageInit (DocumentParser::executeParser)
    - OnLogPageHit (DocumentParser::executeParser), if track_visitors is on
    - OnLoadWebPageCache (DocumentParser::prepareResponse)
    - OnLoadWebDocument (DocumentParser::prepareResponse)
    - OnParseDocument (DocumentParser::parseDocumentSource)
    - OnWebPagePrerender (DocumentParser::outputContent)

    Wednesday, August 18, 2010

    Double action (GET & POST) posted! Modx Manager

    When you encounter this type of error, its due to the specification of
    query-string and post form with "a" parameter

    Monday, August 2, 2010

    Modx ChangePwd Chunk sample

    <div id="divChangePassword" style="position: relative; display: none;">
    <form method="POST" name="changepwdfrm" action="[+action+]">
    <input type="hidden" name="cmdwebchngpwd" value="1" />
    <input type="hidden" name="passwordgenmethod" value="spec" />
    <input type="hidden" name="passwordnotifymethod" value="e" />
    <div><label for="oldpassword">Existing Password</label><input type="password" name="oldpassword" /></div>
    <div><label for="specifiedpassword">New Password</label><input type="password" name="specifiedpassword" /></div>
    <div><label for="confirmpassword">Retype Password</label><input type="password" name="confirmpassword" /></div>
    <input type="submit" value="Save" />
    </form>
    </div>

    Some useful way to get ip and computer name via php

    To get the user’s IP use the following script:
    phpGetHostByName($REMOTE_ADDR);

    To get the user’s computer name use the following script:

    phpgethostbyaddr($_SERVER['REMOTE_ADDR']);

    Sources:

    Friday, July 9, 2010

    Disabling captcha when captcha is not being display

    update `modx_system_settings` set setting_value='0' where setting_name='use_captcha';