Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pawel 22 posts 42 karma points
    Oct 09, 2012 @ 20:48
    pawel
    0

    how to automatically create different title tags

    Hello guys,

    In one of my projects I would like to find a way of automatically creating title tags for some documents. However por SEO purposes I would like them  to be slighty different for every subpage. Is there any way to achive that?

    thanks in advance!

  • Mike Chambers 635 posts 1252 karma points c-trib
    Oct 10, 2012 @ 14:11
    Mike Chambers
    0

    you can leverage the umbraco event handler framework... on create automatically populate the title param...

     

    public class SetDefaultsHandler : ApplicationBase
        {
            public SetDefaultsHandler()
            {
                Document.New += new Document.NewEventHandler(Document_New);
            }
    
            void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
            {
                Document doc = (Document)sender;
    
                try
                {
    
                    doc.getProperty("altTitle").Value = "SOME TEXT CONSTRUCT";
                }catch{}
            }
        }
  • pawel 22 posts 42 karma points
    Oct 11, 2012 @ 20:10
    pawel
    0

    Thanks a lot Mike, I am not really sure how to use your script :(

    I figured out a bit different solution. I am planning to create a few macros with different descriptions or titles and then pull them by using one of the properties of my documents. I struggle a bit with it as I cannot directly pass value from property to macro. When I do:

    <umbraco:Macro Alias="<umbraco:Item field="titleNumber" runat="server" />" runat="server"></umbraco:Macro>

     although in html I can see that value has been passed it do not actually pull the macro...

    Any way to do that? 

     

     

  • Mike Chambers 635 posts 1252 karma points c-trib
    Oct 12, 2012 @ 10:36
    Mike Chambers
    0

    With regards to using the above script... you need to build a class library in Visual Studio, generate the dll and simply place in your bin folder on your site.

     

    with regards to your workaround... I think you probably need your macro to to ask for the titleNumber in the macro script and then you can use the inbuilt

    umbraco.library:RenderMacroContent()

    http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent

  • pawel 22 posts 42 karma points
    Oct 14, 2012 @ 22:06
    pawel
    0

    Thanks a lot for your tips Mike! I realized how little I know and spent a few last days changing this :)

    Got a bit distructed in the process but I am making a good headway and will try to sort this problem out soon. 

Please Sign in or register to post replies

Write your reply to:

Draft