Bootstrap / Clean Theme - Removing site link from the logo

Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -
Number of replies: 15

Hi

I've been playing around with the Less files to change colours etc, but I have come stuck with the site link that is automatically put on a logo when you add one using the Clean settings screen.

Is there a way to disable the site link from the logo?

Regards

Patrick

 

Average of ratings: -
In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

If you look in theme/clean/layout/general.php you will find this code and removing the section I have highlighted will remove the link for you.

        <?php
    if (!$haslogo) { ?>
        <h1><?php echo $PAGE->heading ?></h1>
        <?php
    } else { ?>
         <a class="logo" href="<?php echo $CFG->wwwroot; ?>" title="<?php print_string('home'); ?>"></a>
        <?php
    } ?>

Average of ratings: Useful (2)
In reply to Mary Evans

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

Thanks Mary that was driving me nuts trying to work out how to get rid of it. 

I tried just removing the highlighted area, but kept the hover state as though it was a link and just refreshed the page when you clicked it.  I tried replacing the line with:

         <a class="logo"></a>

This got rid of the hover state.

Regards

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

Hi,

I've just updated to moodle 2.5.1, Which has brought some changes to Bootstrap and Clean.  I've applied to above change again but this fails to work.  I think the lib.php is overriding this, but I could be wrong!

Any help appreciated.

Regards

 

Patrick

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Julian Ridden -

Have you cleared your theme cache after applying the change?

Julian

In reply to Julian Ridden

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

I've purged the cache several times and no effect. 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

I've been playing around with this for a while to no avail!

The update to the Bootstrap and Clean Theme in 2.5.1 has removed the general.php in the layout folder.  The some functions have now moved to the lib.php file.

I have found the line of code that triggers the link:

        $return->heading = html_writer::link($CFG->wwwroot, '', array('title' => get_string('home'), 'class' => 'logo'));

Any ideas on how to modify this to leave the logo but remove the link and hover state?

Regards

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Yes...

Change that line to read like this...

$return->heading = html_writer::link('', array( 'class' => 'logo'));

Purge all caches and 'Bob's your uncle!'

cheers

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

Hi Mary

Thanks for the info.  I have tried the above change and purged the cashes.  However, it removes the logo altogether and replaces it with a text link 'Array'.

Am I missing something?

Regards

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by David Scotson -
That function takes three arguments, the url, the text and the attributes. Mary's missed one out.

http://phpdocs.moodle.org/HEAD/core/lib/html_writer.html#link

You could add '' (an empty string) as the second argument so you've got a link with no url, and no text, but with a class of "logo".

Not sure if it'll work, as I've not tested it, but that's the reason you see the text "Array" anyway,

dave
Average of ratings: Useful (1)
In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

It would be easier to write is like this...

$return->heading = html_writer::tag('div', array('class'=>'logo'));

You would need to rewrite the CSS to dispense with the a.logo and write div.logo instead!
This way you would not need to bother about hover etc...

less of this

duh

and more of this 

yeah!


Cheers

Mary
Average of ratings: Useful (1)
In reply to Mary Evans

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

Thanks Dave - I originally tried what you suggested to remove the actual link address, which works.  However, the logo still has a link state and when clicked it refreshes the screen.  As the logo is just under the breadcrumbs and Navbar, it can accidentally be clicked by mistake.

Thanks Mary - I have tried the revised line and changed the line of code and amended the a.logo to div.logo in the css, but the logo is not appearing and just showing the word 'Array'.

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by David Scotson -
It's just the same issue again, the parameter for the content of the div (which can be "" i.e. the empty string ) is missing. Add that and the "Array" will go away.

Not sure why the logo isn't appearing though. If the HTML and CSS are both changed to be different but match each other it should work.
Average of ratings: Useful (1)
In reply to David Scotson

Re: Bootstrap / Clean Theme - Removing site link from the logo

by Patrick Appleyard -

Thanks David

Adding the extra '' has sorted the image appearing.  The changed code has stopped it returning back to the root, but the link state is still present with the image and refreshes the page when it is clicked.

Regards

 

In reply to Patrick Appleyard

Re: Bootstrap / Clean Theme - Removing site link from the logo

by William Lu -
Picture of Particularly helpful Moodlers

Yes, the link is annoying. 

Have you got final solution to remove the link, which can be triggered from whole wide top area. No user friendly at all. 

Link only logo make sense.

Please help.

Thanks

In reply to William Lu

Re: Bootstrap / Clean Theme - Removing site link from the logo

by John Smith -

2.7 I also wanted to remove the moodle link - I am not sure if that is against the rules or not, but if so, please advise.

To do so all I did was go to site admin/appearance/themes/clean and add custom CSS

.sitelink {display: none;}

which is supported majority of browsers

It is still there of course, but hidden.

Don't know if that helps exactly what you are trying to achieve.


you could then add the logo back into the Footnote, although position is changed slightly.


This works for us no coding people ;)

Average of ratings: Useful (1)