file.php

file.php

by Ilias Vassilopoulos -
Number of replies: 3
Hello there,

Is there a way that I can echo something on the top of each of my custom page via the file.php file?

My goal is: when I add a resource to a course with the method of: Link to a file or website, I want some words to appear by default on the top of this webpage that I upload or make. But I don't won't to write them each time on every page. I thought that maybe this would happen via the file.php because this is the file that sends the page to be displayed.

An example would be:
http://www.mymoodlesite.com/file.php/35/lesson1/lesson1.html
For instance, I want to display a message at the top of this page not by having written it in lesson1.html but somewhere in a core moodle file like file.php

I hope my query isn't science finction.

Thank you in advance.
Ilias
Average of ratings: -
In reply to Ilias Vassilopoulos

Re: file.php

by Jason Hardin -
Your best best would be to do a include in the file you are attaching, so like a server side include for html or to create a custom resource type that does what you are looking to do.

file.php actually send s the file with the correct mimetype for the file to display correctly in the browser. You actually want to display the file inline or in an iframe.

A resource type is going to be better for this.

Your other option would probably be to hack file.php to wrap the request to send_file in an iframe. I wouldn't recommend this as it would be hard to maintain compared to a well developed resource type.
In reply to Jason Hardin

Re: file.php

by Ilias Vassilopoulos -
Firstly, thank you very much Jason for your concern.
Your first thought is what I do till now. And that's exactly what I want to avoid because I upload lots of files and it's a little bit tiring and time-consuming to include the file each time. What exactly do you mean by resource type? I think the solution of the iframe would work well for me but I can't think of how it could be implemented in action.
In reply to Ilias Vassilopoulos

Re: file.php

by Jason Hardin -
a resource type is a new plugin in the mod/resource/type directory.

It allows you to control the display of a resource and add a new type in the add a resource drop down for a course. You could develop one that allows you to upload a file and then displays your wrapper information around the file displayed inline.