Page 1 of 1

Re: Attn Theme Developers... We need an intervention

Posted: Sun Apr 28, 2013 5:40 am
by sputnik-1
People should not hack the base code for making their extensions and themes to work. This is not the way to do it. If they must make modifications to various tag attributes, then I'd suggest using phing and the ReplaceRegexp filter to add their own tag attributes without changing the existing base code tag attributes.

http://www.phing.info/docs/guide/stable ... laceRegexp

http://www.phing.info/

Here are some example phing xml scripts:

The following script took 44 seconds to change all the CR/LF line endings to Linux format:

Code: Select all

<?xml version="1.0" ?>

<project name="changing MS-DOS CR/LF EOL to UNIX EOL chars" default="main" basedir=".">

  <target name="main">

    <echo msg="changing MS-DOS CR/LF EOL to UNIX EOL chars" />

    <reflexive>
      <fileset dir="./upload">
        <include name="**" />

        <exclude name="tmp-backups/**" />
        <exclude name="**/*.xml" />
        <exclude name="**/*.xml.bak" />

        <exclude name="**/images/**" />
        <exclude name="**/zip-file/**" />

      </fileset>

      <filterchain>
        <replaceregexp>
          <regexp pattern='&#xD;&#xA;' replace="&#xA;" />
        </replaceregexp>
      </filterchain>

    </reflexive>

  </target>

</project>
The output from the running script:

Code: Select all

[root@karsites opencart-1.5.5.1]# phing -f change-eol.xml
Buildfile: /downloads/Ecommerce/OpenCart/1.5.5.1/opencart-1.5.5.1/change-eol.xml

changing MS-DOS CR/LF EOL to UNIX EOL chars > main:

     [echo] changing MS-DOS CR/LF EOL to UNIX EOL chars
[reflexive] Applying reflexive processing to 2440 files.

BUILD FINISHED

Total time: 44.4178 seconds

Phing is very fast at doing inline editing tasks!

This phing script adds a custom stylesheet attribute to the php documentation downloads - (I don't like a plain white background - it gives me eye strain)

Code: Select all

<?xml version="1.0" ?>

<project name="adding stylesheet tag" default="main" basedir=".">

  <target name="main">

    <echo msg="adding stylesheet tag..." />

    <reflexive>
      <fileset dir=".">
        <include name="*.html" />

<!--
        <include name="**/*" />

        <exclude name="tmp-backups/**" />
        <exclude name="*.xml" />
        <exclude name="*.xml.bak" />
        <exclude name="**/*.xml" />
        <exclude name="**/*.xml.bak" />
-->

      </fileset>

      <filterchain>
        <replaceregexp>
          <regexp pattern="<head>"
                  replace="<head> <link rel="stylesheet"
type="text/css" href="MY-style.css" />" />

        </replaceregexp>
      </filterchain>

    </reflexive>

  </target>

</project>

So the above phing script looks for the <head> tag, and changes it to:
<head> <link rel="stylesheet" type="text/css" href="MY-style.css" />

Would it not be possible to do this for custom OC extensions, so at least the original tag attributes are remaining?

Re: Attn Theme Developers... We need an intervention

Posted: Mon Apr 29, 2013 2:51 am
by GoGo OpenCart
sputnik-1 wrote:Would it not be possible to do this for custom OC extensions, so at least the original tag attributes are remaining?
http://code.google.com/p/vqmod/

Re: Attn Theme Developers... We need an intervention

Posted: Tue Apr 30, 2013 3:36 am
by sputnik-1
Very neat solution.

Would this not also work using JQuery on the client side, to alter/add tag attributes?