I’m trying to make an extension that will change the title of a page (see Using heading from page as title )
I’ve generated the extension and added this code:
def after_configuration
@app.sitemap.register_resource_list_manipulator(
:heading_as_title,
self,
false
)
end
# A Sitemap Manipulator
def manipulate_resource_list(resources)
resources.each do |resource|
resource.add_metadata :page => {
'title' => 'Manipulated title',
'new_metadata' => 'A new piece of metadata'
}
end
end
When I run it it will add the new title to resource.metadata[:page]['title']
It will however not change the value of resource.data.title
, which remains as the original title.
And when the page is rendered to be shown in the browser,
current_page.metadata[:page]['title']
will contain the new title, but
current_page.data.title
will contain the original title,
the result being that the page shows the original title, not the new one.
I’ve tried moving the activation of my extension, testing to first and last, but this has no effect.
I’ve tried changing the register_resource_list_manipulator
third value to true
, to force an early rebuild of the sitemap, but no effect.
I also tested to add a new metadata element (‘new_metadata’), to rule out the possibility of a conflict with the existing title definition. But this new element behaves the same, it’s present in the metadata
but does not make it to current_page.data
.
How do I make my change of the title stick?