1
nmshah
hacking publisher and its clones to use same instances of js and css
  • 2012/3/14 18:08

  • nmshah

  • Just can't stay away

  • Posts: 556

  • Since: 2007/7/2 8


Tutorial to use the same css and .js file for all clones of publisher.
1. First I made the following changes to the publisher module
a. Publisher/footer.php line25
Changed
$xoTheme->addStylesheet(PUBLISHER_URL '/css/publisher.css');

To
//$xoTheme->addStylesheet(PUBLISHER_URL . '/css/publisher.css');


b. Publisher\include\functions.php
Changed line 37
<link type="text/css" href="' . PUBLISHER_URL . '/css/publisher.css" rel="stylesheet" />

To
//<link type="text/css" href="' . PUBLISHER_URL . '/css/publisher.css" rel="stylesheet" />

c. Publisher/item.php
Changed lines 44 to 47
From
$xoTheme->addStylesheet(PUBLISHER_URL '/css/jquery.popeye.style.css');
$xoTheme->addScript(XOOPS_URL '/browse.php?Frameworks/jquery/jquery.js');
$xoTheme->addScript(PUBLISHER_URL '/js/jquery.popeye-2.0.4.js');
$xoTheme->addScript(PUBLISHER_URL '/js/publisher.js');

To
// $xoTheme->addStylesheet(PUBLISHER_URL . '/css/jquery.popeye.style.css');
// $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
// $xoTheme->addScript(PUBLISHER_URL . '/js/jquery.popeye-2.0.4.js');
// $xoTheme->addScript(PUBLISHER_URL . '/js/publisher.js');

The above steps are taken to stop the module from adding css & js files to the site
(* I don’t use the rating function in any instance of publisher so did not touch behavior.js or rating.js.)

2. Next copied
a. publisher.js and jquery.popeye-2.0.4.js
from
modules/publisher/js/
to
themes/mytheme/js/

b. publisher.css and jquery.popeye.style.css
from
modules/publisher/css
to
themes/mytheme/css

3. Load the css and js files directly in the theme

a. Loading jquery from googleapi

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

b. Loading js and css files only in publisher module
<{if $xoops_dirname=='publisher'}>
<
link rel="stylesheet" type="text/css" media="all" href="<{xoImgUrl css/blog.css}>" />
<
link rel="stylesheet" type="text/css" media="all" href="<{xoImgUrl css/ jquery.popeye.style.css}>" />

  <
script type="text/javascript" src="<{xoImgUrl js/publisher.js}>"></script>
  <
script type="text/javascript" src="<{xoImgUrl js/ jquery.popeye-2.0.4.js }>"></script>
<{/if}>

4. Checked that the module is working as it should on my site after the above changes.
5. Cloned the module using the cloning feature in the admin area. The new modules are blog & work
6. Modified the templates of both blog and work to change css id and class. Replaced blog / work with publisher, everything else remaining same.

So for example in templates/blog_display_full.html
<div class="blog_collaps_title">

Becomes
<div class="publisher_collaps_title">


7. Also in all templates wherever there is a javascript code
replaced
$blog

With
$publisher


So for example in templates/blog_item.html
Line 170 to 181

Changed

<script type="text/javascript">
    <!--
//<![CDATA[
    
$blog(document).ready(function ()
    {
        var 
options = {
            
caption:    'permanent'
        
}

        
$blog('#ppy3').popeye(options);
    });
    
//]]>-->
</script>

To
<script type="text/javascript">
    <!--
//<![CDATA[
    
$publisher(document).ready(function ()
    {
        var 
options = {
            
caption:    'permanent'
        
}

        
$publisher('#ppy3').popeye(options);
    });
    
//]]>-->
</script>


8. Installed blog and work from the module installation section
9. Updated theme to include the css and js in blog and work module too.

Changed in the above point 3 (b)
<{if $xoops_dirname=='publisher'}>

To
<{if $xoops_dirname=='blog' || $xoops_dirname=='work' || $xoops_dirname=='publisher'}>


10. Checked blog and work module to see that they are working correctly.

So now I have three instances of publisher using the same css and js.

2
Mamba
Re: hacking publisher and its clones to use same instances of js and css
  • 2012/3/14 18:28

  • Mamba

  • Moderator

  • Posts: 11256

  • Since: 2004/4/23


Thank you for doing this tutorial! I am sure, others will benefit from it.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Login

Who's Online

73 user(s) are online (45 user(s) are browsing Support Forums)


Members: 0


Guests: 73


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits