Forums | Mahara Community
Developers
/
Display dynamic message on homepage
01 May 2015, 1:55
Hi,
Is it possible to display a dynamic message according to the logged in user profile?
I'm currently using Mahara 1.7 and I believe it is possible to use something like:
{if $USER->is_institutional_staff()}
<!---Block of html for teachers--->
{else}
<!---Block of html for everyone else--->
{/if}
However, I've tried adding this to the 'show homepage information' text from the admin area and it is just displayed as text. Is there something I'm missing?
Thanks for any assistance you can provide.
01 May 2015, 7:10
I'm guessing maybe this needs to be added directly to the template file rather than within the editing options in Admin?
03 May 2015, 20:50
Hello Andrew,
Another possibility (but only in later versions of Mahara) is the following which wouldn't require coding: If you have not hooked up your Mahara to a Moodle site, you could put all your teachers into one institution and all your students into another. And then you can set different messages for them on the homepage. See http://manual.mahara.org/en/15.04/administration/institutions.html#institution-static-pages for more information.
The added benefit is that you could also give your teachers a different theme than what the students get and give them different permissions in terms of public pages, seeing online users etc.
Cheers
Kristina
07 May 2015, 3:19
Thanks - this is all useful information to experiment with. When I've got it working I will report back with what I've used.
23 May 2015, 2:47
Just to follow up - we've got this working now exactly as proposed. By updating the homeinfo.tpl file we've got a dynamic display that shows content depending on the user profile.
24 May 2015, 15:20
Hi Andrew,
Great that you got it to work. Do you have a write-up of your idea to share with others in case someone is interested in your solution to achieve something similar?
Cheers
Kristina
22 June 2015, 23:05
Hi - there isn't actually too much more the solution than the original request. However, I would be happy to write up if that will help others.
In fact, I have since discovered a further challenge:
{if $USER->is_institutional_staff()}
<!---Block of html for teachers--->
{else}
<!---Block of html for everyone else--->
{/if}
works really well as it displays teacher content for teachers and then changes it for others. However, as we've some some users who aren't institutional staff I'm actually looking to change the code so it will display specific content to students instead.
It is turning the code on its head really.
However, is this a valid command or is there anything similar that anyone is familiar with?
if $USER->is_student()
Could be used for:
{if $USER->is_student()}
<!---Block of html for students--->
{else}
<!---Block of html for everyone else--->
{/if}
24 June 2015, 11:14
Hi Andrew,
Sorry, we don't have an "is_student()" function. We've actually never had a use for it in Mahara core, because admins & staff can do everything students can do.
So, you'll just need to check that the user isn't staff or admin:
{if !($USER->get('admin') || $USER->get('staff') || $USER->is_institutional_admin() || $USER->is_institutional_staff())}
<!-- block of HTML for students -->
{else}
<!-- block for everyone else -->
{/if}
Cheers,
Aaron
- «Previous page
- 1
- 2
- »Next page