Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

how to add id to link tag which refers to your themes style.css

jackmaessenjackmaessen ✭✭✭
edited March 2016 in Vanilla 2.0 - 2.8

I want to add an ID to only this link tag:

<link rel="stylesheet" type="text/css" href="/themes/bootstrap/design/style.css?v=2.5.1" media="all" />
Per example:
<link id="switchlink" rel="stylesheet" type="text/css" href="/themes/bootstrap/design/style.css?v=2.5.1" media="all" />

In applications/dashboard/modules/class.headmodule.php there is this function:

    public function addCss($HRef, $Media = '', $AddVersion = true, $Options = null) {
                $Properties = array(

                    'rel' => 'stylesheet',
                    'type' => 'text/css',
                    'href' => Asset($HRef, false, $AddVersion),
                    'media' => $Media);

Adding ad id to this associative array gives all the link tags that ID. Only the one to my themes/bootstrap/design/style.css should should get that ID.
How can i do that?

Comments

  • R_JR_J Admin
    public function base_beforeToString_handler($sender, $args) {
        $tags = $sender->tags();
        foreach ($tags as $key => $value) {
            if (substr($value['href'], 0, 40) == '/applications/dashboard/design/style.css') {
                $tags[$key]['id'] = 'stylish';
            }
        }
        $sender->tags($tags);
    }
    
  • Awesome! I had to change line 4 to this

    if (substr($value['href'], 0, 34) == '/themes/bootstrap/design/style.css') {but the intention was clear to me.Works perfect. Thanks @R_J

Sign In or Register to comment.