Make header image clickable - Canvas theme, Moodle 2.0

Make header image clickable - Canvas theme, Moodle 2.0

by Richard Miller -
Number of replies: 5

Just like the subject line says, I'd like to make the image in my header a clickable link - but don't have a clue where to do this.

Help? Thank you!

Canvas theme, Moodle 2.0.

Average of ratings: -
In reply to Richard Miller

Re: Make header image clickable - Canvas theme, Moodle 2.0

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

Hi,

The html for this is easy enough, and that's basically all you need. However getting the image to display in Moodle needs PHP so you would first need to upload the image (logo.png or logo.jpg or logo.gif) to your theme/canvas/pix directory and then add the following to the theme's layout files, general.php, frontpage.php and report.php, where you see the <h1> tag, like so...

<h1 class="headermain"><?php echo $PAGE->heading ?><a href="http://google.com"><img src ="<?php echo $OUTPUT->pix_url('logo','theme') ?>"  alt="image"  height=" " width=" " /></a></h1>

The grayed italic setting adds the Site/Course title to your Frontpage/Course pages respectively, so if you dont want that just delete that section

However, because CANVAS is a parent theme and used by many Moodle 2.0 themes, you are advise NOT to change this theme, but copy (clone) it.

You can read how to do this in Development: Themes 2.0 how to clone a Moodle 2.0 theme

HTH

Mary

Edited!

In reply to Mary Evans

Re: Make header image clickable - Canvas theme, Moodle 2.0

by Richard Miller -

Thanks, Mary.

I'd already zapped the H1 tags, so i added that code to the "page-header" div. Worked like a charm ...

In reply to Mary Evans

Re: Make header image clickable - Canvas theme, Moodle 2.0

by David Kimball -

Mary, I am trying to get this to work in my Magazine Theme.  In my frontpage file, the $Page->heading "redirects" to $hasheading and am unsure where to put the code.  I have experimented with different places to no avail.

Here is my header code:

 

<!-- start of header -->

<div id="header-wrap">
    <div id="header-container">
        <div id="header">
            

            <div id="headleft">
            
            </div>

            <div id="headright">
            <?php if ($hasheading) {
            echo $OUTPUT->lang_menu();
            echo $OUTPUT->login_info();
            echo $PAGE->headingmenu;
            }
       
            ?>
            </div>
            
        </div>
    </div>
</div>
<!-- end of header -->

 

 

Any ideas?

 

David

In reply to David Kimball

Re: Make header image clickable - Canvas theme, Moodle 2.0

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

There is a settings page where by you can set a logo if you want. There is no need to add this as a hard coded extra.

If you have not found the Magazine setting's page yet, you need to go to Settings > Site Administration > Appearance > Themes >> and CLICK on the Magazine (link) which is one of a list of theme name at this point.

If no Logo is set then it reverts to just the Site name as can be seen in this code here...

<!-- start of logo and menu section -->
    <div id="textcontainer-wrap">
        <div id="textcontainer">
        <?php if (!empty($PAGE->theme->settings->logo)) { ?>
            <div class="thetitle">
                <div class="innertitle">
                </div>
            </div>
        <?php } else { ?>
            <div id="nologo" <?php if(!$hascustommenu) {echo "class='nomenu'";} ?>>
                <a href="<?php echo $CFG->wwwroot; ?>" title="Home"><?php echo $PAGE->heading ?></a>
            </div>
            <?php } ?>

Hope this helps?

Mary

In reply to Mary Evans

Re: Make header image clickable - Canvas theme, Moodle 2.0

by David Kimball -

Yes, I do set my own logo in the Magazine admin page as you described.  I applied your code as highlighted above, but my header graphic is still not clickable.

I even went in and took out the logo reference so it would revert to the default "Magazine" logo.png file.