Hello,
I think I did this exactly how you said, but in my index.html nothing
shows up. Here is what I have:
my_app/defaults.py
from mezzanine.conf import register_setting
register_setting(name='test_text', default="Hello world")
register_setting(name="TEMPLATE_ACCESSIBLE_SETTINGS", append=True,
default=("test_text",))
my_theme/templates/index.html
{% extends "base.html" %}
... all defaults
{% block main %}
{% blocktrans %}
<h2>My text!</h2>
<p>Here is my text and the variable is: {{ settings.test_text }}</p>
{% endblocktrans %}
{% endblock %}
I get the first part of the text, but the variable is not there at all.
thanks,
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 7/16/2015 12:12 AM, Danny wrote:
On 16/07/2015 7:30 AM, Brandon Keith Biggs wrote:
Hello,
Is there an easy way to create template variables and functions
without modifying the site urls?
Perhaps in mezzanine_tags or something?
A variable like
{{ mezzanine.my_app.my_variable }}
would be fine.
Is this what page can help with? I want to use these variables in my
custom theme.
thank you,
I think what you might be looking for is to create your own setting,
and then use it in a template, right?
http://mezzanine.readthedocs.org/en/latest/configuration.html
Basically:
In your app, create a defaults.py, and use register_setting() to
create the variable you want.
It can be editable in the admin if you like, or just configurable via
settings/local_settings.py
Then you'll need to update TEMPLATE_ACCESSIBLE_SETTINGS so that your
new setting is listed there,
making it accessible within templates.
And then you should be able to just reference {{settings.variable}} in
any template that has mezzanine_tags loaded.
For example, I have in my app's defaults.py:
register_setting(
name="SOCIAL_FACEBOOK",
description="Link to Facebook Page. Include http prefix.",
editable=True,
default="",
)
register_setting(
name="TEMPLATE_ACCESSIBLE_SETTINGS",
append=True,
default=("SOCIAL_FACEBOOK",),
)
And then in my base.html:
{% load mezzanine_tags ... %}
...
{% if settings.SOCIAL_FACEBOOK %}
<a href="{{ settings.SOCIAL_FACEBOOK }}">Facebook</a>
{% endif %}
So this allows me to add a link to my Facebook page in the admin
(Settings section) and have that link show up on every page of the
site via the base.html template.
Seeya. Danny.
--
*Danny Sag*
Chairperson
Round World Events SA, Inc
City of Small Gods Terry Pratchett Fan Club -
http://cityofsmallgods.org.au
*Nullus Anxietas VI - The Australian Discworld Convention* -
http://ausdwcon.org
"The Discworld Grand Tour" - Adelaide SA, August 4-6, 2017
--
You received this message because you are subscribed to the Google
Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Mezzanine
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.