WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • x_find_class
  • Print
Pages: [1]   Go Down

Author Topic: x_find_class  (Read 8812 times)

aldus

  • Guest
x_find_class
« on: August 27, 2008, 11:00:01 AM »
Hello

In this german thread Stefek comes up whithin a question
for an code-modul witch will check out the page-content for
a given tag and a matching classname.

https://forum.WebsiteBaker.org/index.php/topic,10855.0.html

e.g. find all tags of type <pre> with the classname "code", an if
even one is found, add a specific css and/or javascript file.

Ok - here it is, a little bit beta and a little bit "confuse" but it's
working in the first tests;


after installing the modul you can modify/add the following function in your
template:
Code: [Select]
<?php

if (function_exists("find_my_class") ) {
      
$path_to_css = array (
          
WB_URL."/modules/x_find_class/test.css"
      
);
      
$path_to_js = array (
          
WB_URL."/modules/x_find_class/test.js"
      
);
      
      
ob_start();
        
page_content();
        
$content = ob_get_contents();
    
ob_end_clean();
    
    
find_my_class($content, "pre", "code", $path_to_css, $path_to_js);
}
?>


As you can see the first argument is the page-content-string, followed by
a tag-type whithout the "<", then comes the classname (here "code") and
the last two arguments are the path to the css/js files.
You can pass 0 or "" for not including the file, or a valid filename, or
an array, if you are in the need of including more files.
If the files are not found a warning-message will be produce, including the requestet filename.

Any recomentations, bugfixes, improvements, discussions or "schimpfe" as always welcome.

Edit: Version 0.1.7
- Minor Bugfixes in the regex.
- Additional path-testings in "__file_exists" e.g. the ini-settings for "allow_url_fopen".    
- Minor cosmetic changes and version-cleanings
- Changes for the "warning-messages" - now as a comment.

Edit: Version 0.1.6
- Minor Bugfixes and additional comments, informations

Edit: Version 0.1.5
- Bugfix for "file_exists" within absolute paths.
- Minor cosmetic changes
- Add. a "test.js" and "test.css" in the package-folder
- Update the example above ...

Regards
Aldus

[gelöscht durch Administrator]
« Last Edit: September 26, 2008, 03:11:37 PM by aldus »
Logged

aldus

  • Guest
x_find_class update 0.1.7
« Reply #1 on: September 26, 2008, 03:12:56 PM »
Ok - the last version 0.1.7 is ready for download now.
Some changes - see first entry below.

Regards
Aldus
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • x_find_class
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2