Sitefinity 5.X: Override how page title is generated - sitefinity

http://www.sitefinity.com/devnet/forums/sitefinity/developing-with-sitefinity/override-how-page-title-is-generated.aspx#2050837
I would like to override how the page titles for all pages on a site are generated. The client wants the title to be similar to the site breadcrumb where it is a concatenated list of ancestral page names plus the current page.
I figure that this could be generated when a page is saved but I would have to alter the page title of the current page and all child pages. If I did it this way then if they changed their mind later then I would have to regenerate all of the page names.
Alternatively if I could just override how the page titles are put on the page then I could go get the ancestors and generate the title when the page is viewed by a user.
I lean toward the second but I don't know how to do either. Any ideas?
I am working on 5.X.

just cross posting the answer you got on the forums in case anyone is looking here.
The answer from Liam was to refer to this KB article: http://www.sitefinity.com/devnet/kb/sitefinity-4-x/globally-overwriting-properties-for-frontend-pages.aspx
which allows you to use global.asax to override the properties globally. pretty slick, I wasn't aware of it!
My suggestion was if you need to do it at the template level to use the SiteMapBase.GetActualCurrentNode() method to do it manually.
hope you got it all worked out!

Related

How can I add a custom page to Shopify without the /pages/ URL?

I want domain.com/custompage, but the built in functionality puts all pages inside a /pages/ directory so the URL comes out domain.com/pages/custompage which I don't want.
I found this answer from a Shopify Guru in 2016 that mentions potentially setting up a custom HTML template or using an app, which no longer exists.
Any clues on how to achieve this? I have limited experience with Shopify templates, but could figure it out if someone could point me in the right direction.
This blogger says it can't be done:
"Q: Can you create pages on the root? A: The answer to this is no –> all pages have either /pages/, /collections/ or /products/ in the URL."
However others have told me it is possible. Just not how to do it.
Create a section Name "test" // first a step
Create a page json Name "test" // The second step
After creating the page, JSON does a section test

Get blog post custom field in template head - Sitefinity

I need to set several meta tag values in my page head to values set in blog post custom fields.
How do I access the blog item viewmodel from the head?
I've created a separate MVC view snippet for my custom head and referenced it in my template's layout, that much works.
Tried
I grab some of the same custom field values inside my blog template via references like Model.Item.Fields.MyFieldName.Fields.Title.
Adding this same line to the head template throws a
System.Web.HttpCompileException with little useful information attached. I somewhat expected this, as I suspect that viewmodel for the blog post only exists in the context of the blog widget.
Ends up that I need to rebuild after every change to the head cshtml file or I get this error. Seeing as this is about a four-minute process with Sitefinity (15 seconds to build, 3:45 to do whatever Sitefinity does for about four minutes), this is a gruelingly horrid thing to have to do.
However the Model is null at this level.
Also tried
Per the ever-helpful and highly knowledgeable #Veselin Vasilev, I looked into passing the data up via MetaDataFields. I didn't see these options in my admin section for the widget. To clarify, I'm using the built-in "Blog posts" widget with a customized view file.
But if it's possible to do this, it gives me hope that there's a way to pass more data up, even if it's going to take some work.
EDIT: Sitefinity v.10.2 and above:
There is an easier way to achieve what you are trying - in Page edit mode, in the Blog Posts widget click Edit and then Advanced. Then you should see a MetaDataFields button. Click it and you should see several meta data related fields.
In the MetaTitle field put the name of your custom field and save.
Also, from the docs:
If you leave MetaTitle field empty, Sitefinity CMS adds takes its value from the Title field of the static content item or from the identifier field of a dynamic content item. Otherwise, the tag is populated with the contents of the field that you have entered in MetaTitle field.
More details here:
https://docs.sitefinity.com/configure-meta-title-and-meta-description-on-widget-level
Sitefinity 10.1 and below:
Check this article
Basically, in your view you get a reference to the Page object and then update its Header with the meta data you need.

Sitefinity 4.4 - Dynamically change page title and description at runtime

Does anyone know how to dynamically change the page title in Sitefinity from a regular user control?
Our scenario is simple. We have a real estate website with a search feature. On the search results page we have a control showing the search results, but we need to be able to change the Page title, description and keywords based on the search performed.
We posted on Telerik, but they gave vague answers and pointed us to incorrect objects or objects that didn't actually work.
?
Regards,
Jacques
The way I've usually done this in the past is by using an external widget template.
By mapping your widget template to an external file, you can use a full User Control (.ascx file) which means you can also run code behind.
From there it's just a matter of running something like
Page.Title = "whatever";
For more info on using an external template for Sitefinity Widgets, check out this post: http://www.sitefinity.com/blogs/joshmorales/posts/11-05-10/mapping_external_templates_for_sitefinity_4_widgets.aspx
Hope this is helpful!

Programmatically adding metatags to Masterpages in Web Forms and MVC

Has anyone got any ideas on where we should be adding our SEO metadata in a Web Forms project? Why I ask is that currently I have two main Masterpages, one is the home page and the other one is every other page, they both have the same metadata that’s just a generic description and set of key words about my site. The problem with that is search engines are only picking up my home page and my own search engine displays the same title and description for all results.
The other problem is the site is predominantly dynamic so if you type in a search for beach which is a major categories on the site you get 10000 results that all go to different information but all look like a link to the same page to the user.
edit
It's live here www.themorningtonpeninsula.com
Don't know why this post was moved here either, I put it up on stackoverflow.com. I didn't know about this site but I'm glad I do now!
It is in its essence a programming question and the answer is to use dynamic meta tags to your pages and your the master pages. If you do a search on this most of what comes up is "How to add meta tags to your masterpages" that's easy but not a good idea!
Put this in the page_load of you page then populate the hard coded bits from the database.
Page.Header.Title = "Some new dynamically created page Title!";
Page.Header.Description = "Some dynamically created description";
Page.Header.Keywords = "stuff, more stuff, even more stuff";
HtmlMeta myMetaTag = new HtmlMeta();
myMetaTag.Name = "robots";
myMetaTag.Content = "noindex";
Page.Header.Controls.Add(myMetaTag);
Does the trick.
Cheers,
Mike.
Not sure why this got migrated here since it's really a programming question. To answer the SEO aspect: yes, all pages should have unique titles that describe the page, and usually a relevant meta description.
Note, search engines are picking up all your pages, as a search for site:www.themorningtonpeninsula.com will show you. But since they all have the same title they are probably not appearing in normal searches.
For the technical side, you can definitely set the page title when using master pages in ASP. I think you can set the title when you create a new page, but if not the first line of each page should have the title attribute like in this code from one of my projects. Here the title would be "Help pages":
<%# Page Language="VB" MasterPageFile="~/MasterPage.master" CodeFile="Help.aspx.vb" Inherits="Help" title="Help pages" %>
I'm not 100% sure about the meta description but it should be possible to set that in the VB/C# code behind the page. If you can't get it working I'd recommend asking a more specific programming question on Stack Overflow.

How do I change the default landing page in a Trac wiki?

A default Trac installation will display the WikiStart page as its home page. I'd like it to display another page. How do I do that? I was unable to find anything with Google, as any request with "Trac" in it will return links to every opensource project that uses Trac.
If you want to keep the "Welcome to Trac" page, have you considered simply migrating that content to a new page and then editing WikiStart? Trac documentation upgrades leave the WikiStart page unchanged (as documented here), so you aren't making trouble for yourself in that regard.
Are you wanting to display a different wiki page, or a different kind of page? I don't know of a config option for the former, but you can use [trac] default_handler in your trac.ini to make, say, the custom query page be the default page.
Edit: Taking a quick glance over the sources, WikiStart is pretty well hard-coded as the start page for the wiki. So, short of patching Trac, I don't think you can do what you're after.
It seems there's no hope in overriding /wiki URL path to render a wiki page other than WikiStart. That's hardcoded by design (maybe for a very good reason).
On the other hand you can use configuration options in [mainnav] section to override Wiki link in main navigation area and make it point at a custom wiki page e.g.
[mainnav]
wiki.label = Home
wiki.href = /wiki/HomePage
see details in trac:wiki:TracInterfaceCustomization#CustomNavigationEntries
If your Trac installation is behind Apache, then you can use an Apache configuration directive to redirect or rename the "home page" url. For example, look at the "Alias" directive.
My solution to the same problem was to use the [[Include]] macro (http://trac-hacks.org/wiki/IncludeMacro), and have the WikiStart page contain a single include statement.
I wanted a different page name than WikiStart so I could use the page name prefixes to categorize sets of pages, e.g., MyToolNameIntroduction is my start page.
This trac ticket suggests it is not directly possible: http://trac.edgewall.org/ticket/9012