Documentation Page and Title #5092

Closed
petrklus opened this Issue Mar 18, 2016 · 2 comments

Projects

None yet

3 participants

@petrklus

The example provided for the "populate" method for Title extension is not correct:

def populate(self):
    # setup the extension toolbar with permissions and sanity checks
    current_page_menu = self._setup_extension_toolbar()
    # if it's all ok
    if current_page_menu and self.toolbar.edit_mode:
        # create a sub menu
        position = 0
        sub_menu = self._get_sub_menu(current_page_menu, 'submenu_label', 'Submenu', position)
        # retrieves the instances of the current title extension (if any) and the toolbar item URL
        urls = self.get_title_extension_admin()
        # cycle through the title list
        for title_extension, url in urls:
            # adds toolbar items
            sub_menu.add_modal_item('icon for title %s' % self._page().get_title(),
                                    url=url, disabled=not self.toolbar.edit_mode)

As there is no self._page(). (error 'HeroImageExtensionToolbar' object has no attribute '_page')

Also, the documentation does not include a template example when using Title instead of Page extension. I have resorted to using context processor to get it to show up in my template:

def add_hero(request):
    print request
    return {
        "heroimageextension" : request.current_page.get_title_obj_attribute("heroimageextension")
    }

Then in template

{% if heroimageextension %}
    {{ heroimageextension.hero_image.url }}
{% endif %}

But that is hardly ideal (having to have it in the settings etc.). Please provide a nicer way to do this!

@evildmp evildmp was assigned by czpython May 18, 2016
@evildmp
Contributor
evildmp commented Jan 10, 2017

@petrklus You are right that the example for populate() is incorrect; a patch is coming to address that.

I don't see what the issue is with templates is though, or why you needed a context processor.

@evildmp evildmp added a commit to evildmp/django-cms that referenced this issue Jan 10, 2017
@evildmp evildmp Improved Page and Title extension documentation
* improved Page example
* corrected Title example so it actually works properly
* removed broken example from cms.toolbar.ExtensionToolbar comments

Fixes #5092
Fixes #5083

[ci skip]
b4bc252
@evildmp evildmp closed this in #5845 Jan 11, 2017
@evildmp evildmp added a commit that referenced this issue Jan 11, 2017
@evildmp evildmp Improved Page and Title extension documentation (#5845)
* improved Page example
* corrected Title example so it actually works properly
* removed broken example from cms.toolbar.ExtensionToolbar comments
bonus: removed out-of-date note about redo/undo from documentation home page

Fixes #5092
Fixes #5083
580d06e
@petrklus

@evildmp Thank you for picking it up - if I recall correctly, I simply could not see the extension in the template without the template processor. It's a while back so probably safe to drop it, I will create another issue if I notice the behaviour again (and will be able to test it more)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment