Shoult style sheets be attached to the master style?
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #1
Shoult style sheets be attached to the master style?
I barely need to ask for general help, and it is very frustrating when you notice that the official MyBB support team gives an orange about your support threads. So I apologize for almost copy/pasting my question over here Zinga Burga, but this is the last place where somebody can actually help me on this.

I have too plugins that inserts new style sheets to the themes,those sheets are inserted into the master style, so you cannot deleted them (just like you can't delete global.css). Those sheets' content can easily moved to the global.css or showthread.css files to remove one extra file from being loaded (two when in showtread.php).

Quote:ougc_annbars.css (Inherited from MyBB Master Style)

How are we suppose to insert new sheets in such way that it is MyBB friendly (I can just pack a "read-me" file with instructions of what to include in the xx.css file, but IMO that is no "MyBB friendly") and that those can be deleted as well?

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
08-21-2012 04:40 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: Shoult style sheets be attached to the master style?
If you want the Admin has an ability to delete it, don't insert it using MyBB Master Style id.

08-21-2012 06:24 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: Shoult style sheets be attached to the master style?
Up to you really.  I don't think there's any 'friendly' functions for doing this.
If you want to modify global.css, I'd imagine it's just editing it in the DB then updating the cache file (check MyBB's ACP code on how they do it).

(08-21-2012 04:40 AM)Sama34 Wrote:  the official MyBB support team gives an orange about your support threads
That sounds generous, unless the orange is perhaps more brown in colour.
Generally you don't get much (or worthwhile) support for more advanced topics.  Basic stuff typically gets answered well enough.

My Blog
(This post was last modified: 08-21-2012 11:12 AM by ZiNgA BuRgA.)
08-21-2012 11:12 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #4
RE: Shoult style sheets be attached to the master style?
(08-21-2012 06:24 AM)RateU Wrote:  If you want the Admin has an ability to delete it, don't insert it using MyBB Master Style id.

So I will need to query a list of TID of all the themes in the forum, then insert a style sheet in each one? Basicaly this should work, right?:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
$query = $db->simple_select('themes', 'tid');
while($theme = $db->fetch_array($query))
{
	$db->insert_query('themestylesheets', array(
		'name'         => 'ougc_annbars.css',
		'tid'          => (int)$theme['tid'],
		'attachedto'   => '',
		'stylesheet'   => $db->escape_string('/*--content--*/'),
		'lastmodified' => TIME_NOW
	));
	update_theme_stylesheet_list($theme['tid']);
}


(08-21-2012 11:12 AM)ZiNgA BuRgA Wrote:  Up to you really.  I don't think there's any 'friendly' functions for doing this.
If you want to modify global.css, I'd imagine it's just editing it in the DB then updating the cache file (check MyBB's ACP code on how they do it).

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
$query = $db->simple_select('themestylesheets', 'sid, tid, stylesheet', "name='global.css'");
while($theme = $db->fetch_array($query))
{
	$theme['stylesheet'] .= '/*--content--*/';
	$db->update_query('themestylesheets', array('stylesheet' => $db->escape_string(unfix_css_urls($theme['stylesheet'])), 'lastmodified' => TIME_NOW), "sid='{$theme['sid']}' AND tid='{$theme['tid']}'");

	if(!cache_stylesheet($theme['tid'], 'global.css', $theme['stylesheet']))
	{
		$db->update_query("themestylesheets", array('cachefile' => "css.php?stylesheet={$theme['sid']}"), "sid='{$theme['sid']}'", 1);
	}

	update_theme_stylesheet_list($theme['tid']);
}


That seems a better way to go, now what about those who already installed this, I hate upgrade scripts No

(08-21-2012 11:12 AM)ZiNgA BuRgA Wrote:  That sounds generous, unless the orange is perhaps more brown in colour.
Generally you don't get much (or worthwhile) support for more advanced topics.  Basic stuff typically gets answered well enough.

"very" and "orange" were replacements for other words, no really that kind of guy and was very upset when writing it.

The support team should be able to answer this kind of questions, or at least pretend/try to do so, IMO. It is very frustrating to be bumping your threads to the top for days to notice they don't.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
08-21-2012 12:43 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #5
RE: Shoult style sheets be attached to the master style?
You shouldn't need to loop through all themes if you're adding it to the master theme.  You'll probably have to go through all themes without a parent (ie pid=0) and add the stylesheet there, then loop through all themes and update the stylesheet list to include yours.

If you update global.css, you would have to loop through all themes, then handle the case that the user could add new themes, which won't contain your modification.
Perhaps MyBB's weakest point in their theme and template system is that there's no really good way to manage these deltas between possible plugin and theme modifications.

Alternatives:
- include the CSS file separate from the MyBB themes system - I'd personally do this, then in the readme leave it up to the user if they want different styles for different themes
- chuck CSS into templates

(08-21-2012 12:43 PM)Sama34 Wrote:  now what about those who already installed this, I hate upgrade scripts No
So you've told users to already stick CSS in there?

(08-21-2012 12:43 PM)Sama34 Wrote:  The support team should be able to answer this kind of questions, or at least pretend/try to do so, IMO. It is very frustrating to be bumping your threads to the top for days to notice they don't.
I don't know...  I prefer no information over misinformation.

My Blog
08-21-2012 01:12 PM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #6
RE: Shoult style sheets be attached to the master style?
hm... to much pain for just some minimal stuff. Probably will just include a readme file telling users what to do with the CSS file's content (I don't like templates to do style sheets job either). My current method could be more suitable for plugins that include custom php files (i.e: awards.php).

Quote:So you've told users to already stick CSS in there?

No, but I hate any update script anyways (mostly because I live-update my plugins in my live board, so it is difficult to keep track of the changes being made), and if those using the plugin do edit the default things of plugins or mybb it self to fit on their tastes, they most probably already edited it anyways.

Quote:I don't know...  I prefer no information over misinformation.

You are most probably right, I'm still upset about it.

Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
08-21-2012 02:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: Shoult style sheets be attached to the master style?
(08-21-2012 12:43 PM)Sama34 Wrote:  So I will need to query a list of TID of all the themes in the forum, then insert a style sheet in each one? Basicaly this should work, right?:
[php]$query = $db->simple_select('themes', 'tid');
If you do that, it'll insert your stylesheet into all themes, including the Master style.

08-27-2012 05:10 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: