protostar inline css [solved]

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Post Reply
Koos O
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Aug 11, 2017 8:40 am

protostar inline css [solved]

Post by Koos O » Sun Aug 05, 2018 9:15 pm

I notice that in protostar index.php an inline css is created that alters user css code at some point.

For instance: if you want to change the colour of a link I used to fo that with custom css
/* linken paars maken*/
a {
color:#732645;
}

Now I the custom css plugin is no longer there so I use user css and find that the index.php overrules the user css.

That seems to me a bug in the system. Why should index.php overrule things?

I solved the issue true deleting in index.php this line whre links are set to the template color.
a {
color: ' . $this->params->get('templateColor') . ';
}

But that's not a great way to act because with every new update I have to do it again. Is there a better way to change the color of the links?
If I use !important; in the user css it overrules the index.php but that is also no good solution (it works to good).
Or is this a bug in the system. The index.php should not create inline css?
Last edited by mandville on Mon Aug 06, 2018 11:26 pm, edited 1 time in total.
Reason: marked solved as per op

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 35914
Joined: Sat Apr 05, 2008 9:58 pm

Re: protostar inline css

Post by Webdongle » Sun Aug 05, 2018 9:34 pm

The css in the template's index.php is read after any css files ... therefore it overrides previous css.

The code that you deleted is there to display the value given by the settings in Joomla's admin. Best not edit it.

If you need to edit the file then make a copy and edit the copy. Otherwise you will loose your changes.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

User avatar
sozzled
Joomla! Champion
Joomla! Champion
Posts: 5871
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: protostar inline css

Post by sozzled » Sun Aug 05, 2018 9:40 pm

Thank you for your question. I would like to make two points:

1) Never, under any circumstances (except where you will never update the software that you use on your website and you are prepared to run the risk that your site will be hacked), change original software. This includes making changes to Protostar's index.php or template.css files.

I realise, of course, that a lot of people ignore this advice. That's OK. If people want to change original software in order to make something work then I say good luck to them. You can do whatever you want to do but, before people go wild and do whatever they want to do, they need to be reminded that there are consequences.

People can minimise these consequences by creating CSS files to store their unique, personalised customisations or create template overrides that will fix the "issues". I also realise that everyone has different abilities and expertise in handling how to write CSS or create template overrides. The point that I want to make here is that the solution that one person finds to solve their problem may not suit everyone and may, in fact, cause other problems for others.

2) While it may not be good "programming practice" to use the !important CSS rule modifier, there's no commandment that outlaws the use of !important. This doesn't mean that people should use !important whenever they want to (or because they're too lazy); I would suggest that people should first try to change the behaviour of an element on a page without using the modifier. If the behaviour changes only with the !important then you've found a solution.

Another solution is to use a different template.

I don't think there is a "bug" in Protostar. I agree that you've discovered one of several limitations within Protostar but it's not a limitation that can't be easily overcome.
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 24888
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: protostar inline css

Post by Per Yngve Berg » Sun Aug 05, 2018 10:08 pm

Another solution is to use a more specific selector in your css.

Code: Select all

div a.myclass {
color:#732645;
}
Adding the a as a child of a div or with a class will override just a "a".

Koos O
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Aug 11, 2017 8:40 am

Re: protostar inline css

Post by Koos O » Mon Aug 06, 2018 10:29 pm

You are absolutely right Sozzled! That's why I post my question.

Thank you Per Yngve, your solution works but I have to adjust more then 300 articles :-(

I found another solution that works fine for me. In the user.css I added the following lines. They do the job and in occasions that an incidental link needs another color I can chance it with html style colour (and that could not be done if I used !important in the css.

/* link color purple-red*/
a:link {
color: #732645;
}
a:hover {
text-decoration: underline;
color:#732645;
}
a:visited {
color:#732645;
}

Thank you all for responding


Post Reply

Return to “Templates for Joomla! 3.x”