More in this section

Forums / Developing with Sitefinity / Categories and tags - absolute URL's

Categories and tags - absolute URL's

4 posts, 0 answered
  1. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    13 Feb 2010
    Link to this post
    Hi,

    I'm looking for a way to define category and tag urls as absolute and not relative urls.

    Is this possible? If so how will I go about doing this?

    Thanks,

    Anthony
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Feb 2010
    Link to this post
    Hello Anthony Smith,

    Could you elaborate some more about which urls you want to change? Generally categories and tags are associated with IContent objects. Using absolute path is not a good practice, because once the project is moved the path will not be resolved correctly. Furthermore we use dynamic links to prevent such problems.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    15 Feb 2010
    Link to this post
    Hi Ivan,

    I want to specify where content under a particular category or tag appears, when I click on that link. This will ensure that all content with the particular tag or category will appear in the same location (irrespective of content type).

    For example all content, all news, etc when i click on the category / tag link it would redirect me to the following absolute url:

    www.domain.com/category-name
    www.domain.com/tag-name

    Instead of for example www.domain.com/news/category-name or www.domain.com/blog/category-name

    Thanks,

    Anthony
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Feb 2010
    Link to this post
    Hello Anthony Smith,

    You can achieve this using UrlRewriting. You need to create url rule with regular expression which matches the urlrewrite. CategoriesTree control uses QueryStrings - "CatID" where value key is the ID of a catagory. You need to override CategoriesTree control and instead of working with CatID as a guid you need to use CategoryName.

    sample

    protected override void InitializeControls(Control controlContainer)
            {
                base.InitializeControls(controlContainer);
     
                ....
                          ....
     
                this.CategoriesTreeView.ShowLineImages = ShowLineImages;
                this.CategoriesTreeView.MaxDataBindDepth = MaxDataBindDepth;
                this.CategoriesTreeView.NodeDataBound += this.CategoriesTree_NodeDataBound;
                this.CategoriesTreeView.AppendDataBoundItems = true;
     
                BindCategories();
     
                if (ExpandAllNodesByDefault)
                    this.CategoriesTreeView.ExpandAllNodes();
                else
                    this.CategoriesTreeView.CollapseAllNodes();
     
            }
     
          ....
               ....
    void CategoriesTree_NodeDataBound(object sender, RadTreeNodeEventArgs e)
            {
                e.Node.NavigateUrl = HERE SET THE URL TO THE CATEGORY NAME;
            }


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered