Форумы / Cotonti / Extensions / CSS called by plugin

Davide
#1 22.11.2012 23:37

Hi,

I am writing a plugin for Cotonti that I want to have use its own CSS file.  Can someone please advise how I call the CSS file..I.e which plugin file do I need to add an 'include' statement and anything else I need to do.  I don't want the CSS to be in my skin/theme CSS file.

I saw this was done in the 'tags' plugin but didn't quite follow.  My plugin won't have as many .php files

many thanks

David

lukgoh
#2 23.11.2012 08:56

I was going to say in tags.resources, but it looks like its just a comment?

/*$R['tags_code_style'] = '<link rel="stylesheet" type="text/css" href="'.$cfg['plugins_dir'].'/tags/style.css" />';*/

 

Added 2 minutes later:

Ignor that, its in tags.rc.php:

cot_rc_add_file($cfg['plugins_dir'] . '/tags/tpl/tags.css');

 

Davide
#3 23.11.2012 09:47

Hi, yes, thanks, I see that...problem is, my plugin doesn't have a resources file (it's a plugin adapted from LDU/Seditio).

I'm using a very simple set of .php files in my plugin and wondered if it could go in the main php plugin file or the config.php file?

Thanks again

David

Отредактировано: Davide (23.11.2012 13:36, 11 лет назад)
Trustmaster
#4 23.11.2012 17:13

If you only want to use it on your plugin page and you are not going to consolidate it with other site stylesheets, then you can simply add it using cot_rc_link_footer() function in your main php file:

cot_rc_link_footer($cfg['plugins_dir'] . '/myplug/tpl/myplug.css')

 

May the Source be with you!
esclkm
#5 23.11.2012 18:00

footer is not valid for html

littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Davide
#6 23.11.2012 18:13

Yes, the CSS is 'just' for a particular plugin.  I thought there would be a way of calling it from the plugin itself.  I know I can't use include() as this just prints the CSS to screen as opposed to applying it to the output from the plugin.

pas I said, I saw this was done for the 'tags' plugin but this is a very complex plugin. Mine is very simple and only outputs through the .tpl for the plugin, under plugin.php page. (This is a standalone plugin, I.e it doesn't hook or tag into any other parts of Cotonti, just onto the plugin page)

Many thanks

David

Trustmaster
#7 23.11.2012 19:38

I forgot that in a plugin standalone part you can also do cot_rc_link_file():

cot_rc_link_file($cfg['plugins_dir'] . '/myplug/tpl/myplug.css');

 

May the Source be with you!
Davide
#8 24.11.2012 13:50

I'll give this a go.  Thank you for your help

 

David

Added 2 hours later:

Uhm....slight problem,

Genoa doesnt have the cot_rc_link_file() function in functions.php...can I just copy/paste that function from Sienna's functions.php and paste into Genoa's functions.php and everything will be ok?

David

Отредактировано: Davide (24.11.2012 15:36, 11 лет назад)
Macik
#9 25.11.2012 20:10

Nop, `cot_rc_link_file` is use other `cot_rc_*` functions.

But, as I remember, you can use something like this:

$out['compopup'] .= '<link href="'.$file.'" type="text/css" rel="stylesheet" />\n'; 

where $file contains filename with path to your CSS.

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Davide
#10 25.11.2012 23:06

Macik,

Thanks. Where should I include this line, in my main pluginname.php?

How/when is $out['compopup'] parsed?

as an aside, anyone have an overview of how Cotonti starts up?, by this I mean, the sequence of operations it runs through before it parses and presents the 'homepage' of the website?

thanks

david

Отредактировано: Davide (26.11.2012 01:44, 11 лет назад)
Trustmaster
#11 26.11.2012 06:30

Ah, so you're using Genoa. Then things are slightly different because in Genoa your main pluginname.php is executed after the header part is rendered. So you need to add another part to your plugin to add that CSS file to header:

<?php
/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=pluginname
Part=header
File=pluginname.header
Hooks=header.main
Tags=header.tpl:{HEADER_COMPOPUP}
Order=10
[END_SED_EXTPLUGIN]
==================== */

defined('SED_CODE') or die('Wrong URL');

if (defined('SED_PLUG') && $e == 'pluginname')
{
	$out['compopup'] .= '<link rel="stylesheet" type="text/css" href="'.$cfg['plugins_dir'].'/pluginname/tpl/style.css" />';
}

 

May the Source be with you!
Davide
#12 29.11.2012 14:04
Thank you, I'll give this a go.

davide

Added 3 weeks later:

No...sadly, this wont work...my plugin doesn't have that part...what I did do was put:

  $echo "<link href='plugins/standard/pluginname/css/style.css'  type='text/css' rel='stylesheet'>";

into my pluginname.config.php and it worked a treat.

Thank you

david

Отредактировано: Davide (21.12.2012 07:15, 11 лет назад)
lukgoh
#13 21.12.2012 09:30

The correct way would be to create a php page called pluginname.header.php and copy and paste Trustmaster's code (changing the parts to match up with your plugin.) 

Luke.

Davide
#14 21.12.2012 19:38

Agreed!

once it's all completed and tested, I'll do that.

thanks for your input

kind regards

david