Manipulating .htaccess through install.xml

Discussion in 'Subrion CMS Plugins Discussion' started by wazza, Feb 3, 2014.

  1. wazza

    wazza Member

    Hi guys im just wondering i there is a way to manipulate .htaccess through the install.xml of a plugin i am creating.

    I have a callback script.....

    What i need to do is have the .htaccess rule so that the file is

    I can do this manually i know but i need a way to generate the .htaccess rule when the plugin is installed.

    I hope you understand.

  2. wazza

    wazza Member

    I do recall being able to do this before just cant seem to find a plugin with the reference....I think the old SITEMAP plugin done it (before you made it part of the core)
  3. wazza

    wazza Member

    ive tried playing with adding a page but will not work with a blank value

    <page url="callback/" name="callback" readonly="1" menus="main" filename="callback"></page>
  4. Janur_J.

    Janur_J. Staff Member


    In order to execute your custom PHP file there is no need to manipulate with the .htaccess file.
    Playing with page XML entries is the only valid way to include custom code.

    This will work:
    But should be written using CDATA markers as per below:
    This will force the script to connect your file (script_path/plugins/plugin_name/callback.php) when visitor opens the page at
    Also, the following variables will already be included to namespace: $iaCore, $iaView, $iaDb.

    In your case, I would recommend to exclude the menus="main" attribute, since it would add this page with an empty title to the main menu. Just specifying the title instead of empty CDATA instruction could also be a solution.

    Please take a note that you may call this page also as and callback.xml
    This will set the appropriate request type, you can check it by calling iaView::getRequestType(). It returns one of the iaView::REQUEST_HTML, iaView::REQUEST_XML, iaView::REQUEST_JSON constants. You may run different code for particular type of request, fyi almost all of script's plugins work like this.

    Hope it helps :)
    wazza and Vasily B. like this.
  5. wazza

    wazza Member

    Thank Janur. Great Explanation!. :D I did work it out with CDATA but i didnt realize i could call .json and .xml that is great to know. The call back works perfectly.

    I should have the plugin avaliable in a day or two:D

    Thanks Again
    Last edited: Feb 4, 2014
  6. Vasily_B.

    Vasily_B. Project Manager

    Janur, thanks for the detailed explanation here. It seems to be a good candidate to be listed in our WIKI section.

    Just one question. AFAIK we have two ways to make page JSON calls.
    a. callback.json
    b. callback/read.json
    Could you please confirm if this is true and what would be the recommended way?

  7. wazza

    wazza Member

    Hi guys just noticed that if i add &timestamp into a template file it results in it outputing xtamp

    I am adding data to the database via a callback script and saving the time stamp to the database.

    the call looks like this

    I need to let the users of the plugin know what to put into the 3rd partys website call back field when setting up the plugin. So need to display the above callback url.

    Is there a workaround for this i should i just rename the &timestamp to something else?

  8. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    @Vasily B. AFAIK, callback/read.json method is preferred and callback.json doesn't work since 3.1.2 version.
    @wazza &times is interpreted as a "cross symbol" html entity, not even as an "x". In order to prevent this you should replace all "&" symbols in the url with "&amp;"
    This should do the trick.
  9. wazza

    wazza Member

    Thanks Alex.... All good :D

  10. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    Glad to advice!
  11. Janur_J.

    Janur_J. Staff Member

    Currently, both ways are valid. At the same time, the second option, when you specify the action name too, is preferred.

Share This Page