BobRay / MyComponent

Development environment for creating MODX extras
https://bobsguides.com/mycomponent-tutorial.html
23 stars 13 forks source link

/ in Template Name Creates Directory #18

Closed jmaddington closed 10 years ago

jmaddington commented 11 years ago

Using a forward slash in a template name that is set to be static results in the creation of a directory.

E.g., "My template w/ something special" would results in: modx/assets/mycomponents/[...]/elements/templates/my_template_w/_something_special.html"

Expected behaviour would be for the template to be created at: modx/assets/mycomponents/[...]/elements/templates/my_template_w__something_special.html"

BobRay commented 11 years ago

Try replacing the section (around line 213) of the core\components\mycomponent\model\mycomponent\helpers.class.php file with this code:

    /* replace anything that shouldn't belong in a file name
       with an underscore - allows alphanumeric, dot,
       hyphen, and underscore  */
    $output = preg_replace('#[^A-Za-z0-9\._\-]#', '_', $output);

On Wed, Sep 11, 2013 at 9:23 AM, JM Addington notifications@github.comwrote:

Using a forward slash in a template name that is set to be static results in the creation of a directory.

E.g., "My template w/ something special" would results in:

modx/assets/mycomponents/[...]/elements/templates/my_template_w/_something_special.html"

Expected behaviour would be for the template to be created at:

modx/assets/mycomponents/[...]/elements/templates/my_template_w__something_special.html"

— Reply to this email directly or view it on GitHubhttps://github.com/BobRay/MyComponent/issues/18 .

jmaddington commented 11 years ago

That did it.