Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Is it possible to set language "automatic" on Url property from code

Vote:
0

Hi

I have a customer where they have used specific language on their Url properties. They want to change this to "automatic".

Is it possible to do this through code? Im hoping to create a scheduled job to crawl all these properties and change the value.

[Display(Order = 10)]
public virtual Url SomeContent{ get; set; }

#298820
Mar 23, 2023 9:15
Vote:
0

Hi,

I think the internal representation of the link will be in the format:

/link/[content GUID].aspx?epslanguage=[content language]

If you want to change the language to automatic, you should be able to remove the querystring from the URL so you've got a URL in the format:

/link/[content GUID].aspx

#298822
Mar 23, 2023 10:13
Vote:
0

Paul is correct. To get a list of all URL properties with specific language set:

SELECT pkId, String from tblContentProperty 
WHERE fkPropertyDefinitionID IN 
(
  SELECT pkId from tblPropertyDefinition where fkPropertyDefinitionTypeID IN 
  (
	SELECT pkId from tblPropertyDefinitionType WHERE Name = 'Url'
  )
) AND String LIKE '%?epslanguage=%'
#298823
Edited, Mar 23, 2023 10:16
Vote:
0

Hi, thanks for quick response!

So if i understand correctly i should try and remove "?epslanguage="{culture}" on all links directly in the database?

/P

#298827
Mar 23, 2023 11:44
Vote:
0

Database queries are handy for extracting information but I wouldn't recommend changing the data directly in the database. I would suggest using the IContentRepository to update the links to remove the querystring.

#298828
Mar 23, 2023 12:06
Vote:
0

I couldnt change the actual query directly so I had create a new Url object and store that instead.

So far it seems to work.

var clone = currentPage.CreateWritableClone() as GeneralPageModel;
if (clone != null)
{
    clone.Video.VideoUrl = new Url(clone.Video.VideoUrl.Path);
    _contentRepository.Save(clone, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);
}

#299063
Edited, Mar 27, 2023 20:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.