Hi.
Would somebody be so kind to explain in more detail or give an example of how to use the file_rewrite_pluginfile_urls function. I have some basic/modest SQL knowledge so I'm able to make some SQL statements directly on moodle database tables in order to customize my moodle based web page. But I'm struggling with this @@PLUGINFILE@@ instead of URL to file (e.g. image)
So, I found this explanation:
file_rewrite_pluginfile_urls($text, $file, $contextid, $component, $filearea, $itemid, array $options=null)
- param: string $text The content that may contain ULRs in need of rewriting.
- param: string $file The script that should be used to serve these files. pluginfile.php, draftfile.php, etc.
- param: int $contextid This parameter and the next two identify the file area to use.
- param: string $component
- param: string $filearea helps identify the file area.
- param: int $itemid helps identify the file area.
- param: array $options text and file options ('forcehttps'=>false)
- return: string the processed text.
So, If I have this:
<p><img style="float: left; margin-left: 5px; margin-right: 5px;" src="@ @PLUGINFILE@@/image.jpg" alt="image" width="100" height="85" />Image</p>
inside this:
table: mdl_data_content
attribute: content
id(row): 5732
According to above, is it possible to derive those parameters for file_rewrite_pluginfile_urls function?
I thought maybe it's something like this:
$text = "@ @PLUGINFILE@@/image.jpg";
$component = "mod_database"; >>> according to some example I found with "mod_lesson"
$filearea = "content";
$itemid = "5732";
But probably it's not, or even if it is what about other parameters?
Which files do I have to include (require_once) to my php for this to work?