Forums | Mahara Community

Support /
Adding an additional Static page


anonymous profile picture
Account deleted
Posts: 4

18 September 2014, 0:59

Hi, we are running Mahara 1.9, is it possible to add additional static pages onto to ones are already listed e.g. Terms and conditions? Any ideas on how to do this? Thanks.

18 September 2014, 1:40

Hello Jenny,

Since Mahara 1.9 you can create static pages for each institution. See the manual for more reference :

http://manual.mahara.org/en/1.9/administration/institutions.html#static-institution-pages

Regards,

-dajan

anonymous profile picture
Account deleted
Posts: 4

18 September 2014, 1:48

Hello dajan,

Thanks for getting back to me. Unfortunately these pages have already been customised. What I'm looking to do is add an additional institution static page, for example, for our acceptable use policy. Do you know how to do this?

Many Thanks,

Jenny

18 September 2014, 3:55

Hello again,

If you read further down the doc, you will notice there is a possibility to add more pages and edit them directly with the frontend interface. But this requires some editing of the file named 'lib.php' in your 'local' folder.

I spend the last hour to try to find how to create these pages.

I found that you have to add the following code in the lib.php

function local_site_content_pages(){
   return array('page1','page2');
};

But reading the code I have not found where the html code must be. In the 'local' folder ? In the database ?

I think that Aaron will be able point us to where is the doc about this feature,  or to provide more info on this.

Sorry to not being able to be more helpful on this for now.

-dajan

Robert Lyon's profile picture
Posts: 756

18 September 2014, 8:32

Ok, to be able to add new local static pages you need to do the following steps

1) Add initial static page information.

Static pages are driven from the database rather than being a static html file. So first we need to add some rows to the database to start us off.

In the database you need to add in records to the site_content table, eg:

INSERT INTO site_content VALUES ('pageone', '<p>This is a site test</p>', '2014-09-18 07:30:24', '2014-09-18 07:30:24', null, 'mahara');
INSERT INTO site_content VALUES ('pagetwo', '<p>This is an institution test</p>', '2014-09-18 07:30:24', '2014-09-18 07:30:24', null, 'testinstitution');

The 'pageone' is the internal name which Mahara will keep a track of

Note: the internal names for the pages can only be basic alphabet letters (no numbers or special chars)

set the last value to 'mahara' if you want it to be a site page otherwise set it to the internal name for the institution

But we can edit it yet, so

2) Add ability to select/edit new page from admin screen:

In local/lib.php add the following code:

function local_site_content_pages(){
   return array('pageone','pagetwo');
};

where the array contains the internal names from step 1 that you want to be added to the select box on the admin screen.

Now you should see the option in the dropdown list on the admin 'static pages' edit screen (either site or institutional ones depending on what you set for step 1) but the display name for it will be broken - look like [[pageone/local]] - so

3) We need to define the language string.

So we set up a file local/lang/en.utf8/local.php - you will probably need to make the directories as well - and add this to the new file

<?php

$string['pageone'] = 'Page One';
$string['pagetwo'] = 'Page Two';
?>

If you are using languages other than english you will need to set up the local lang files for those languages as well eg
local/lang/de.utf8/local.php for german, local/lang/fr.utf8/local.php for french, etc...

4) Getting your new static page to display:

Copy the following code into a file and save that file into the local dir, eg local/pageone.php (so that later you can hit http://yourmaharasite.com/local/pageone.php to view the page)


<?php
/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */

define('INTERNAL', 1);
define('PUBLIC', 1);
require('../init.php');
define('TITLE', get_string('pageone'));

$smarty = smarty();
$smarty->assign('page_content', get_site_page_content('pageone'));
$smarty->display('sitepage.tpl');

?>

If you are wanting the page to only be for logged in users remove the line: define('PUBLIC', 1);

 

18 September 2014, 9:22

Hello Robert,

I think it would be a good idea to add your answer to the wiki, where Aaron has already put some info about how to use the 'local folder'

Your answer is the kind of 'missing link' that will help the readers to understand how to engage with the different features the 'local' folder has to offer.

Thanks again

-dajan
Robert Lyon's profile picture
Posts: 756

18 September 2014, 11:32

As the instructions are a bit in-depth I've added this page to the wiki as a mini tutorial:

https://wiki.mahara.org/index.php/Developer_Area/Development_Tutorials/Basic_local_static_page

 

18 September 2014, 9:14

So Jenny

Robert gave you a brilliant answer.

Easy, isn't it?

:-)

Maybe we should ask for a simpler and user friendly solution in futur version of Mahara.

Cheers all

dajan
Aaron Wells's profile picture
Posts: 896

18 September 2014, 13:54

If you're looking for a way to share your Acceptable Use policy, one option might be to use the optional "Links and resources" menu under "Administration -> Configure site -> Menus". You can use the option for "External link" but then put a link to one of your Mahara site pages.

Unfortunately, this would not be customizable per-institution, like Static Pages are. And it puts the link in a new sideblock instead of in the footer alongside "Privacy Stamente" and "About".

Another option, which would be less intensive than creating an entirely new Static Page, would be to use a custom language file to rename one of the existing ones. For instance if you're not using the "Terms and conditions" static page (and by default it is not used), you could rename that to "Acceptable use policy". To do that, you'd create a file called {mahara-dirroot}/local/lang/en.utf8/mahara.php with this content:

<?php
defined('INTERNAL') || die();
$string['termsandconditions'] = 'Acceptable use policy';

Also copy that file to {mahara-dirroot}/local/lang/en.utf8/admin.php (due to awkward code quirk, the string is defined in two places).

Cheers,

Aaron

anonymous profile picture
Account deleted
Posts: 4

19 September 2014, 22:40

Thanks all

10 results