Dirhtml Help - Scripts (File Matching)

General Concept   File matching sections allow specific html code to be inserted based on pattern matching.   Any matching script section must be followed by a single line identifying an external file.

For example:
/FILE_MATCHES_TD
some-external-file.txt


This is a sample valid external file:
/*.mp3|*.ogg
style="border-left: 15px solid olive"
/*.wav
style="border-left: 15px solid blue"


Special case: Insert No Code
If the external file includes a match that contains the insert code "NO_CODE-DIRHTML", matching files won't use any code from the external file.  This makes it possible to have a /NO_MATCH-DIRHTML section that is ignored for certain files.   An example of when this might be useful is if /FILE_MATCHES_A is used for all files except certain types that need to use a /FILE_MATCHES_TD code insert.
Example:
/*.txt|*.doc
NO_CODE-DIRHTML


Special case: no matches
If the external file contains /NO_MATCH-DIRHTML, filenames that have no matching code will use code from the /NO_MATCH-DIRHTML section.
Example:
/NO_MATCH-DIRHTML
class="no-match-class"


File matches are not cumulative (e.g. if the matching.txt file has /*.* and /*.*, only the first html code will be used).  Internally, file match specs are sorted alphabetically, so /a*.* would be before /b*.*, regardless of their position in the matching.txt file.
Note: All /FILE_MATCH sections support %%F, %%F_PATH, %%NO_EXT_FNAME% and %%RELATIVE_PATH variables.
SectionDescription, Use
/FILE_MATCHES_TD Adds text to <td>'s that contain matching file links.  The section must contain only an existing file name (e.g. file_matches.txt), and the external file must use the same flat-file format used by dirhtml scripts, with each potential file match preceded by /, and multiple matches separated by |.
Example:
/FILE_MATCHES_TD
external_file.txt
Code is inserted: <td HERE>
/FILE_MATCHES_A Adds text to the <a> of matching file links
Code is inserted: <a HERE>...</a>
/FILE_MATCHES_BEFORE_A   Adds text before matching file links (before the opening <a)
Code is inserted: HERE<a>...</a>
/FILE_MATCHES_INSIDE_A Adds text before matching file links (before the link text)
Code is inserted: <a>HERE...</a> 
/FILE_MATCHES_INSIDE_A_SUPPRESSED Adds text in place of a filenames; The filename is not shown (e.g. suppressed) for any file with a match
Code is inserted: <a>HERE</a>
 
/FOLDER_MATCHES_TD The same as /FILE_MATCHES_TD, but for links in the folder table
/FOLDER_MATCHES_A The same as /FILE_MATCHES_A, but for links in the folder table
/FOLDER_MATCHES_BEFORE_A   The same as /FILE_MATCHES_BEFORE_A, but for links in the folder table
/FOLDER_MATCHES_INSIDE_A The same as /FILE_MATCHES_INSIDE_A, but for links in the folder table
 
/ANCHOR_MATCHES_TD The same as /FILE_MATCHES_TD, but for links in the anchor table
/ANCHOR_MATCHES_A The same as /FILE_MATCHES_A, but for links in the anchor table
/ANCHOR_MATCHES_BEFORE_A   The same as /FILE_MATCHES_BEFORE_A, but for links in the anchor table
/ANCHOR_MATCHES_AFTER_A Adds text after links in the anchor table
/ANCHOR_MATCHES_INSIDE_A The same as /FILE_MATCHES_INSIDE_A, but for links in the anchor table

/ANCHOR_ROW_MATCHES_TD The same as /FILE_MATCHES_TD, but for anchor rows in the file table
/ANCHOR_ROW_MATCHES_BEFORE_TEXT   Adds text before anchors in the file table
Code is inserted:  HEREThis is an anchor row
/ANCHOR_ROW_MATCHES_AFTER_TEXT Adds text after anchors in the file table
Code is inserted:  This is an anchor rowHERE

Note: /ANCHOR_MATCHES_ROW... sections can use %%COLUMNS% variables

Note: Folders are stored internally as /folder/sub-folder/, and lines starting with // are comments, so use wildcards to match an anchor.
For example:
/?folder/sub-folder/
</td></tr>
<tr class="noborder"><td colspan="%%COLUMNS%" class="note-font">A table row added to folder/sub-folder/
/*data-folder*
This text will be inserted into anchors matching *data-folder*
/NO_MATCH-DIRHTML
This will be added to every anchor that doesn't match another spec