View Single Post
  #8  
Old 01-14-2016, 02:18 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Simple CMS module and custom page code

You can do this in your module when extending pages viewer class to use specific css on specific page

PHP Code:
public function getCSSFiles()
{
    
// get current page id
    
$id = \XLite\Core\Request::getInstance()->id;
    
    
$css parent::getCSSFiles();
    
    
// replace XX with the actual id number
    
if ('XX' == $id) {
        
$css array_merge(
            
$css,
            array(
                
'modules/<Developer ID>/<Module ID>/css_file_name.css',
            )
        );
    }
    
    return 
$css;


In more complicated and ideal example you may want to do an actual search through all pages to find the id you are looking for based on page name (which is something you are more likely to know that the id)

PHP Code:
public function getCSSFiles()
{
    
// get current page id
    
$current_id = \XLite\Core\Request::getInstance()->id;
    
    
// find page id by its name
    // $cnd is the condition for "page name is equal to ..." and if this search
    // condition does not exist in the Repo class you have to create it as well for this to work
    
$target_id = \XLite\Core\Database::getRepo('XLite\Module\CDev\SimpleCMS\Model\Page')->search($cnd);
    
    
$css parent::getCSSFiles();
    
    if (
$target_id == $current_id) {
        
$css array_merge(
            
$css,
            array(
                
'modules/<Developer ID>/<Module ID>/css_file_name.css',
            )
        );
    }
    
    return 
$css;

__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote