Copied to clipboard

Flag this post as spam?

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


  • Tiaan Pat 4 posts 75 karma points
    Jul 14, 2017 @ 07:25
    Tiaan Pat
    1

    Setting property value when using ditto

    Good day,

    I am not that skilled with Umbraco and know very little about the api's. I am using ditto to get a page title set on the document types of a page. I want to dynamically set the title on a partial view or in the controller but can't seem to set the value of the title.

    Currently I am trying this:

    LocationPageModel locationPage = Model.Content.As<LocationPageModel>();
    locationPage.Seo.SeoTitle = "Page Title to go here";
    

    But when I call this on the Master page the SeoTitle is blank. Is there another way to set the SeoTitle without permanently updating the Umbraco databse? Or maybe just updating the current cache to display the change?

    Any help would be appreciated.

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 14, 2017 @ 08:50
    Alex Skrypnyk
    0

    Hi Tiaan

    For changing Umbraco data you have to use Umbraco Services - https://our.umbraco.org/documentation/reference/management/services/

    They are changing database values and updating the cache.

    You can't just change view model and update the database with this code:

    locationPage.Seo.SeoTitle = "Page Title to go here";
    

    Thanks,

    Alex

  • Tiaan Pat 4 posts 75 karma points
    Jul 14, 2017 @ 09:16
    Tiaan Pat
    0

    Hi Alex,

    Thank you for your reply. Like I said in my post, I don't want to update the database, I just want to update the cache for that page to update the page title.

    So I guess there are no other options for achieving what I want to do?

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 14, 2017 @ 09:17
    Alex Skrypnyk
    0

    Tiaan, but you can't update the cache with data that is not the same as in the database, it's not an option.

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 17, 2017 @ 09:35
    Alex Skrypnyk
    0

    Hi Tiaan

    Did you find a solution? Share please with our community.

    Alex

  • Alex Skrypnyk 6133 posts 23952 karma points MVP 7x admin c-trib
    Jul 14, 2017 @ 09:20
Please Sign in or register to post replies

Write your reply to:

Draft