WebFaction
Community site: login faq

I want to create title tags dinamically in my satchmo store. I've configured my satchmo base template with:

<title>{% block title %}{{ shop_name }}{% if pagetitle %}: {{ pagetitle }}{% endif %}{% endblock }</title>

However, {{pagetitle}} is always null, so I am getting always the same title tag (my shop name).

------my base.html head, just in case I'm missing something-------------

{% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency satchmo_discounts app_plugins normalize_decimal  %}
{% block doctype %}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{% endblock %}
<head>
     {% block extra-head %}{% endblock %}
    {% block stylesheet %}<link rel="stylesheet" href="{{ media_url }}css/style.css" />{% endblock %}
    {% plugin_point "page_head" %}
    <title>{% block title %}{{ shop_name }}{% if pagetitle %}: {{ pagetitle }}{% endif %}{% endblock %}</title>
</head>

asked 25 May '11, 18:01

ebou
112
accept rate: 0%

edited 25 May '11, 18:09


I am not sure why that var is null. I spent some time debugging my Satchmo store and could not find any clear setting.

I would recommend you try Django debug toolbar to see if that variable is being passed in a context you can see.

You should also than look in the view code that renders the page to see what code generates that variable.

Lastly I did discover this on satchmo's official docs,

http://www.satchmoproject.com/docs/dev/custom-product.html?highlight=title#extending-the-model-and-templates

This seems to make sense as that would be grabbing the title directly from the product's model, you could also adjust the code to render other parts of that data if you so wish.

permanent link

answered 25 May '11, 19:41

johns
5.4k312
accept rate: 23%

Thanks for your answer!

Still not sure what is happening or why {{pagetitle}}, {{ product.title}} and {{product.meta} are null.

However, I managed to dynamically modify the title tag in all my products & categories pages by adding:

{% block title %}{{ shop_name }}: {{ product.translated_name }}{% endblock %} (in products template)
{% block title %}{{ shop_name }}: {{ category.translated_name }}{% endblock %} (in categories tempalte)
permanent link

answered 26 May '11, 07:48

ebou
112
accept rate: 0%

edited 26 May '11, 07:48

I think you may need to call a context_processor. I may be wrong. I believe this may help, here's how I split the style of my site title.

So I created a variable in settings.py

SITE_TITLE = ("The Epic", "Example")

and then I added these lines to my context_processors.py file

from django.conf import settings

def get_site_title(request): return { 'SITE_TITLE': settings.SITE_TITLE }

I then added a lint to settings.py
TEMPLATE_CONTEXT_PROCESSORS = ('satchmo_store.shop.context_processors.settings',
                               'django.core.context_processors.auth',
                               'project.context_processors.get_site_title',
                               #'satchmo_ext.recentlist.context_processors.recent_products',
                               )
In my template for the header effect I use

<title>{{ SITE_TITLE|join:" " }} - {% block title %}{% endblock %}</title>

This renders for me a regular site title with page name "The Epic Example - Page".

And for the fancy formatting within the page I use this

<h1><span class="logo"><span class="logo_top">{{ SITE_TITLE|first }}</span>
<span class="logo_bottom">{{ SITE_TITLE|last }}</span></span></h1>

And lastly I use CSS to style my site title.

This is the extent I've tampered with any kind of dynamic titling. Maybe this'll help give insight to the problem.

permanent link

answered 26 May '11, 13:03

JBlack
1125
accept rate: 0%

Try title instead of pagetitle.

Instead of

<title>{% block title %}{{ shop_name }}{% if pagetitle %}:
 {{ pagetitle }}{% endif %}{% endblock }</title>

try

<title>{{ shop_name }}{% block title %}{% endblock }</title>
(26 May '11, 13:24) JBlack
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×7

question asked: 25 May '11, 18:01

question was seen: 2,574 times

last updated: 26 May '11, 13:30

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM