Your Moodle version

General plugins (Local): Static Pages

local_staticpage
Maintained by Picture of Alexander Bias Alexander Bias
Moodle plugin which displays information pages which exist outside any course, imprint or faq pages for example, complete with Moodle navigation and theme

The local_staticpage plugin is designed to fetch a static HTML document from disk, enrich it with Moodle navigation and theme and deliver it as a standard Moodle page which exists outside any course.

Static pages will be available on catchy URLs like http://www.yourmoodle.com/static/faq.html and can be linked from Moodle HTML blocks, from your Moodle theme footer and so on. Using the local_staticpages plugin, you can create information pages within moodle, but without misusing a whole course just for showing a textbox.

See README file for details.

Screenshots

Screenshot

Contributors

Picture of Alexander Bias
Alexander Bias (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Darrel Tenter
    Sat, Nov 16, 2013, 1:38 PM
    After much trial and error I’ve determined that I have three issues with the plugin.

    1. Filenames cannot contain non-alpha characters. While testing I discovered that my pagenotfound error was due to having numbers in the static file names. So /static1.hmtl and /static2.html return pagenotfound. But /static loads. If /static.html is in place then /static1.html or /static2.html or /static-1.html load the /static.html content. The plugin is parsing out non-alpha characters.

    2. Plugin doesn’t recognize the user’s lang setting. I did extensive testing with three static files named mypage.html mypage.en_us.html and mypage.de.html. To help me identify them when rendered I coded title and h1 to contain “English” “English US” and “German” accordingly. Accessing my site as a guest I was delivered the correct file according to the site’s language. With only /mypage.html in place (no en_us or de), that version was rendered regardless of the site’s language setting. With only the en_us version in place, but site set to de I get pagenotfound. Vice versa with de.html and language at en_us. So file language recognition seems to work well. However while logged in, my profile's language setting wasn’t recognized by the plugin. The page is always rendered according to the site's language and my profile language wasn’t respected.

    3. Page display breaks with a with a bootstrap-based theme. My theme is customized from Clean (bootstrap base). Afterburner for example works well, assuming the file names are correct. I look forward to your patch to fix this.


    Finally regarding apacherewrite. With it turned on or off the clean urls return 404 not found. I’ve tried .htaccess according to the read me:

    RewriteEngine On
    RewriteRule ^/static/(.*)\.html$ /local/staticpage/view.php?page=$1&%{QUERY_STRING} [L]

    And from your comment above:

    RewriteEngine On
    RewriteRule ^(.*)/static/(.*)\.html$ $1/local/staticpage/view.php?page=$2&%{QUERY_STRING} [L]

    This could be an issue with my apache configuration or mod_rewrite as suggested. I just don’t know enough about that to figure it out, yet.

    Hopefully my discoveries will benefit someone. I'll watch this plugin and test the new release as soon as it's available.

    Thanks,
    Darrel
  • Picture of Alexander Bias
    Mon, Nov 18, 2013, 7:10 PM
    Dear Darrel,

    thank you very much for your extensive testing.

    1. Oh, that's my fault. The readme says that Alphanumeric pagenames are supported, but indeed only alphabetic pagenames are supported. I will fix this bug in the next version.

    2. Your findings are correct - if you want to run staticpages with language detection, you have to make sure that you have a static page file for each language you want to support.
    The issue with your profile's language setting: The language setting in your profile defines, as far as I know, which language is selected after you have logged in. When you select a different language in the language switcher, this selection overrides the setting in your profile for the current session. local_staticpage just get's the current selected language from Moodle core, so I think it can't be blamed for failing here smile

    3. Did you try this with the very last version of Moodle 2.5.x? There were problems with Bootstrap based themes, but I think I had fixed them in my plugin in combination with the latest version of Moodle 2.5.

    4. Concerning your mod_rewrite issues, I am afraid that I can help you very much. The rewrite rules which I have provided should work for most webserver configurations, if they don't work you should have some Apache knowledge to debug the problems....

    Alex
  • Picture of Darrel Tenter
    Mon, Nov 18, 2013, 11:40 PM
    Alex,

    I'm running 2.5.3 Build 20131111. I pulled that last week prior to this plugin.

    I'm researching the Apache Rewrite issue. I have my question out to a few Apache message boards and am hoping for an answer. Or perhaps a fellow Moodler can help here. smile
    Apache Rewrite is enabled on my server. It was suggested by my host to add a line to the .htaccess. Options +FollowSymLinks So I added that.
    I think I understand the syntax of the suggested RewriteRule line, execpt for &%{QUERY_STRING}. I don't know what that part is for.

    Thanks,
    Darrel
  • Picture of Darrel Tenter
    Wed, Nov 20, 2013, 5:15 AM
    Alex,

    Just wanted to let you know that I updated to 2.5.3+ (Build: 20131115) but the theme issue persists. You can see how it looks here.

    http://wxtrainingnw.com/local/staticpage/view.php?page=readme

    I have a 2.6 sandbox installed where I will try your plugin and see what happens. We won't be moving our live site to 2.6 for a while though.

    Thanks,
    Darrel
  • Picture of Alexander Bias
    Wed, Nov 20, 2013, 3:25 PM
    Darrel,

    when I open the URL which you have provided, I get a nicely looking static page saying:
    English page
    My test static page.

    Do you really think that there is still a problem with bootstrap based themes?

    Alex
  • Picture of Darrel Tenter
    Wed, Nov 20, 2013, 4:08 PM
    Sorry Alex but it's not looking correct to me.

    Here are two screen shots. One of my home page, and one of the static page.

    boostrap.png?w=AABTAqoU8_uohejpBgeBe7rYY

    static.png?w=AAB4kAmUbE38CjwOAPtPNGpnJwz

    Is this how it looks to you? The static page certainly isn't embedded in the Moodle body as it shows on your FAQ sample. This works well for me in Afterburner. Also with Bootstrap base, which my theme is supposed to be copied from. Perhaps it's an issue with my theme.

    Darrel
  • Picture of Alexander Bias
    Wed, Nov 20, 2013, 4:22 PM
    Hmm, that's strange. The static page should use the same theme as your normal Moodle does.

    See here:
    Moodle Frontpage: https://moodle.uni-ulm.de/
    Static page: https://moodle.uni-ulm.de/static/impressum.html

    local_staticpage does _not_ switch themes to display the static page. But it does use a suitable pagelayout "standard" to display the static page.

    You said that you use a custom theme which is based on the clean theme. Please check in your custom themes config.php if there is the pagelayout "standard" defined and which template / settings it should use. I assume that your custom theme does not define the standard pagelayout properly, so Moodle falls back to the clean theme for static pages which would explain the theme change.

    Alex
  • Picture of Darrel Tenter
    Wed, Nov 20, 2013, 4:39 PM
    Alex,

    Sending me to the config.php solved it for me! According to your Readme file I had added this to config.php within $THEME->layouts = array(

    'staticpage' => array(
    'file' => 'general.php',
    'regions' => array('side-pre'),
    'defaultregion' => 'side-pre',
    ),

    After reading more carefully I realize this is for "styling static pages in some special way". I removed those bits and voilå! It looks great!
    http://wxtrainingnw.com/local/staticpage/view.php?page=readme

    Thanks for helping me so much with this. It will be very useful for us.

    Now hopefully I can solve the apache rewrite issue and get pretty urls.

    Darrel
  • Picture of Alexander Bias
    Wed, Nov 20, 2013, 5:01 PM
    Darrel,

    great to hear that the plugin finally works for you smile

    Alex
  • Picture of Darrel Tenter
    Thu, Nov 21, 2013, 1:29 AM
    Alex,

    I just solved my .htaccess issue by removing the leading slash before static/ in the RewriteRule


    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^static/(.*)\.html$ /local/staticpage/view.php?page=$1&%{QUERY_STRING} [L]

    or

    RewriteRule ^(.*)static/(.*)\.html$ $1/local/staticpage/view.php?page=$2 [L]


    Either of those work.

    This a great plugin and I think many would find it useful. This type of function should be part of Moodle's core code in my opinion.

    Thanks for all of your help!
    Darrel
  • Picture of Darrel Tenter
    Thu, Nov 21, 2013, 2:05 AM


    I have some solutions that I hope other users of this plugin will find useful.

    Regarding the apache rewrite issue. I discovered that I needed to remove the leading slash before static/ in the RewriteRule. So I now have this:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^static/(.*)\.html$ /local/staticpage/view.php?page=$1&%{QUERY_STRING} [L]

    You can also use:
    RewriteRule ^(.*)static/(.*)\.html$ $1/local/staticpage/view.php?page=$2 [L]

    Now the clean urls work.

    Also, I wanted to add images to my static pages. I put images in /moodledata/staticpage/images. When I put the relative path or the absolute path to the image in the static page html, the image can't be found. I think because this is in moodledata. So I moved my staticpage folder to the Moode http root and reconfigured the plugin to use that location. However when the page is rendered for the clean url the path to the image is getting caught by the RewriteRule. So I created a neighboring folder /staticpage_images and put my graphics there. Then in my static page html my img code is:

    <img src="../staticpage_images/logo.png" alt="logo" />

    If your handy with html I think you can get pretty dynamic with adding static content to Moodle.

    Darrel
  • Picture of Elizabeth Beth
    Tue, Dec 10, 2013, 7:10 AM
    Hello all,
    I don't have a single clue where to post a new question, I'll drop it here I guess.
    We have installed the newest versions of Xaamp and Moodle on a Windows XP pro machine to set up everything locally before we upload to a server. We get as far as setting up the admin stuff, then go to supposed localhost login page to Moodle, but it does not load, just get the page not found error message. The control panel for Xaamp is open with appropriate services running. Even if we try to manually open a Moodle PHP page from the Moodle folder in the Xaamp/htdocs/Moodle directory , nothing happens. Localhosts file is not blocking anything. No firewall is running. Same results in 3 browsers
    Anybody have any ideas on this?
    We are lost
  • Picture of Alexander Bias
    Tue, Dec 10, 2013, 3:24 PM
    Elisabeth,

    after reading your problem explanation I am pretty sure that your "page not found" error has nothing to do with our local_staticpage plugin. Your problem seems to be much earlier in the installation process of Moodle.

    Please ask your question in "Installation help" forum on https://moodle.org/mod/forum/view.php?id=28.
  • Picture of toby saunders
    Fri, Jan 10, 2014, 7:00 PM
    Hi Alexander
    Thanks for you work on this useful plugin. Can I make one suggestion that you include the following in the view.php file after setting the global $page:
    //hack to hide static pages from guests
    if ($CFG->forcelogin) {
    require_login();
    }
    This will mean that if the site has "force users to login" set then the static pages will be behind the login, rather than accessible to anyone.
    Thanks
    Toby
  • Picture of Alexander Bias
    Mon, Feb 3, 2014, 10:19 PM
    Dear toby,

    thanks for your suggestion, it's included in the 2.6 version of the plugin which was just published.

    Alex
1 2 3 4
Please login to post comments