11 years ago
Topic

Hello,

I have a site form for frontend editing.

Template is seb_one, default seb_css3 variation.


Now I need to load extra css for styling of the form. I want to put these styles in an extra stylesheet and load that only when in frontend edit mode. How to achieve this?

When I'm in my content type and go to Site-Form-> Template, there is a section called "Rendering".

Here is an input field called "CSS".

What do I have to put in the field to call an additional style sheet for the site form in frontend edit mode?

The stylesheet that I want to call is  mytemplate/css/edit.css.


Get a VIP membership
11 years ago
3
Level 1

Hello gebeer,

why do you want to load a new stylesheet?

it's more easy to put your css styles in the stylesheet of you Joomla! template, and put a class to your page in the input of the rendering section you have speak about.

If you really want to load your css stylesheet, the simple way it's to do that in a variation.


Best regards.

Lionel

11 years ago
2
Level 2

Hello Lionel,

I want to load an extra style sheet to avoid a large template.css file. The styles needed for the site form should not be loaded all the time.

Thank you for your suggestion with a variation. I will look into that.


Could you please tell me what the input field "CSS" under Site->Template in the section "Rendering" is for?

11 years ago
1
Level 3

Hello,

Could you please tell me what the input field "CSS" under Site->Template in the section "Rendering" is for?



to add class on your page, ( class1 class2 class3 ....) so you can easily design only this specific page.

Regards.
Lionel

11 years ago
0
Level 4

Thank you Lionel.

11 years ago
0
Level 1

Now I found a solution.

I'm using the seb_one template only for site forms. All my other content is handled through different templates (seb_minima).


So I can add some code to the index.php of seb_one which will load my extra css:

$doc = JFactory::getDocument();
$doc->addStyleSheet('templates/'.$this->template.'css/edit.css');

This way edit.css only gets loaded when someone edits a site form in frontend.


This is a workaround that applies only to my situation but maybe it can point people in the right direction when they have a similar situation.

11 years ago
1
Level 1

Hello gebeer,

With your $doc , inside a seblod template, you can use $cck->client to know which view you are, like :

$doc = JFactory::getDocument();
if ( $cck->client == 'site' ) {
	$doc->addStyleSheet('templates/'.$this->template.'css/edit.css');
}

And of course, you can play in the other side, remove some css from seblod like that:

$remove_client_css	=	$this->getStyleParam( 'remove_client_css', 1 );
$remove_cck_css = $this->getStyleParam( 'remove_cck_css', 1 );
$add_custum_css = $this->getStyleParam( 'add_custum_css', 0 );         
$doc = JFactory::getDocument();
$headData = $doc->getHeadData();
     
     if ( $remove_client_css ) {
       unset($headData['styleSheets'][JURI::root( true ).'/media/cck/css/cck.'.$this->client.'.css']);
     }
     if ( $remove_cck_css ) {
       unset($headData['styleSheets'][JURI::root( true ).'/media/cck/css/cck.css']);
     }
     if(!count($headData['styleSheets']))
       $headData['styleSheets'] = array('data:text/css,'=>array('mime'=>'text/css'));
     $doc->setHeadData($headData);
     
     if ( $add_custum_css ) {
       $css_override   =   $this->path.'/css/custum.css';
       if ( $this->isFile( $css_override ) ) {
         $doc->addStyleSheet( JURI::root( true ).'/templates/'.$this->name. '/css/custum.css' );
       }
     }

Best regards

11 years ago
0
Level 2

Hello Alex,

That's great to know. Comes in very handy.

Thank you so much!

Get a VIP membership