how can I get the real address from url like this '@@pulgin....'

how can I get the real address from url like this '@@pulgin....'

by su hang -
Number of replies: 5

how can I get the real address from file path like this '@@pulgin....'

I try the function file rewrite plugin file urls..it does not work


Average of ratings: -
In reply to su hang

Re: how can I get the real address from url like this '@@pulgin....'

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Please explain the context a little more:

  • Is this in your own plugin, or are you messing around with text from another plugin?
  • You say the function 'file rewrite plugin file urls' does not work - I assume you mean 'file_rewrite_pluginfile_urls', this function has been used successfully as part of Moodle core for several years now, so I suspect it is the way you are trying to use it which is wrong, not the function itself.
  • Please give an example of some text with 'https://moodle.org/pluginfile.php/178/mod_forum/post/1126637/' within it which you are trying to use, with the parameters you have passed to 'file_rewrite_pluginfile_urls' and the result you are getting out of this (also with any error messages, or an explanation of what is not working).
Average of ratings: Useful (1)
In reply to Davo Smith

Re: how can I get the real address from url like this '@@pulgin....'

by su hang -
first think you for you help   
second  as the topic  yes  it is my own plugin.Iam indeed want to say the function file_rewrite_pluginfile_urls because I see in the assign/submission/onlinettext  the view function use $this->assignment->render_editor_content() show summary part ,well in the render_editor_content() will use the function to get file path so I think when I include the lib.php It may be work ,but it can not show the image.
then would you please guide me with the contextid and the file storage way the moodle use.
finally looking forword you reply  its to hard to learn without someone help and  It hard to get the information i want in this site can you tell me  some site that will help me with learning moodle programming?
In reply to Davo Smith

Re: how can I get the real address from url like this '@@pulgin....'

by su hang -

I know I can use the function moodle_url::make_pluginfile_url() to construct this URL directl.

but how can get the paramter referred in the function and related to the image I want to show.

think you

In reply to su hang

Re: how can I get the real address from url like this '@@pulgin....'

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If this is the 'intro' text for your activity module, then use the function format_module_intro and that will take care of it for you.

If this is a different field, then you need to use the same params you used when you called file_postupdate_standard_editor to save the files in the first place - namely:

  • component = the frankenstyle name of your plugin (e.g. mod_forum)
  • contextid = the ID of the context for your plugin (e.g. $context = context_module::instance($cmid) )
  • filearea = whatever name you want to give the file area
  • itemid (if used) = whatever id number is relevant to the particular file area you are using (it is your choice as to what to use this number for)


In reply to Davo Smith

Re: how can I get the real address from url like this '@@pulgin....'

by su hang -

thank for you reply

as for the second way  user submit the image in the assign mod  well  I want to show in another mod so how can get the params .as if I only use function  in my mod  dose that mean I can define a constant instand of component,contextid,filearea?

what the relatation between the corsemodule and context(or contextid)? 

what about itemid?


my best wishes

suhang