• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Use Filter To Add CSS

Started by muzemuze,

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

muzemuzeTopic starter

Hello there, in your tutorial you mention that when you add this function to your template it will add css file. I have tried that and it didnt work. Assume I want to add CSS file to the home page.  I added this function to /tpl/main/home.php

<?php 
//The inject custom css and js in your template file. You can attach an add_filter() to them easily.
//http://www.phpvibe.com/phpvibes-add_filter-and-apply_filter/

function more_css( $text ) {
$mycss = '/css/kunani.css';
return $text.$mycss;
}
add_filter( 'filter_extracss', 'more_css' );
?>


Can you point me to the right direction on how to accomplish this?
  •  

Marius P.

Hi! You need to add it to com/com_home.php , since home.php executes after header.


That filter is very wrong. You need a full css link call.
Example:
function more_css( $text ) {
$mycss = '  <link rel="stylesheet" href="../../assets/css/bootstrap.min.css">';
return $text.$mycss;
}
add_filter( 'filter_extracss', 'more_css' );
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Similar topics (7)