User login

Removing Redundant Templates from a Subtheme using a Diff command

in

In Drupal 7, templates in a base theme will be used if an active subtheme does not have that template. This means that there is never a reason to have a template that is identical to what is already in the base theme.

Best Way to See Identical Files

diff --recursive --brief -s issybase issymobile

The -s flag makes diff mention identical files as well as modified ones.

Even better:

diff --recursive --brief -s issybase issymobile | grep identical

This shows only files that are exactly the same in the "issybase/" and "issymobile/" directories (this command would be run from sites/all/themes for instance.

Less Optimal Solutions

Probably can be better yet, but better than visually scanning the output of a recursive diff versus repeated ls (list) commands, which is what i did before...

To see everything different in two directories with diff, but not the detail of each difference, this command can be used:

ben@Onyx:~/code/sdl/web/sites/all/themes (master)$ diff --recursive --brief issybase/ issy/

Producing output like:

Only in issy/: c
Only in issybase/: issybase.info
Only in issy/: issy.info
Files issybase//j/continuum.js and issy//j/continuum.js differ
Files issybase//j/scripts.js and issy//j/scripts.js differ
Only in issy/: sass
Files issybase//template.php and issy//template.php differ
Files issybase//templates/ds-2col.tpl.php and issy//templates/ds-2col.tpl.php differ
Files issybase//templates/page.tpl.php and issy//templates/page.tpl.php differ

So looking at all the files that really were there, deleted the ones that weren't different:

deleted: issy/templates/ds-1col.tpl.php

deleted: issy/templates/field/field--addressfield.tpl.php

deleted: issy/templates/field/field.tpl.php

deleted: issy/templates/file--image--media_viewbook.tpl.php

deleted: issy/templates/html.tpl.php

deleted: issy/templates/html5-1-col--node-project-teaser.tpl.php

deleted: issy/templates/node/node--event.tpl.php

deleted: issy/templates/search-result.tpl.php

deleted: issy/templates/views-view-list.tpl.php

deleted: issy/templates/views-view-table--press-project-images.tpl.php

deleted: issy/templates/views-view.tpl.php

Credit to: http://www.unixtutorial.org/2008/06/how-to-compare-directories-in-unix/

Searched words: 
remove duplicate templates no identical tpl.php files changed tpls

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.