cssmetadatacustom-fieldscustom-field-typesitefinity-8

Sitefinity cms related media link to document using custom field, not loading document path url


I am a beginner for sitefinity, so sorry for long post, not sure if its already answered, couldn't find out. As working on sitefinity-8, looking for best option to select separate css while creating page each time. I know, I can use different theme for different css, which will not work in my case, as we are having long list of css to use in whole site. Also I know, I can add css or any link into the head tag option of page properties or I can add css widget on the page itself to select css for that page only, but our requirement is to select css file while creating the page itself, this will make easy for novice editors too. Basic thing I tried, to add css script tag into template, made it editable on page. So I can select css, but it exposes server folders, which is not ideal. Wish is there any way so that we can configure to select folder from sitefinity content- Documents & Files. But didn't find out a way to do so. Other thing I tries, I have created custom field (related media-images, videos, files) for page to select a document & use as a link to add into head tag (to say link to add css for page.) With this custom field I can select needed document from appropriate folder from sitefinity backend itself, not from server. When I am looking into page source, I could see the link tag is there, but href attribute is empty. I also tried with adding related media tag into template the page is using, but the issue is same, no any value in href attribute. Struggling to resolve this since long time, seeking for expert's advice.Thanks in advance.


Solution

  • The custom field path you've chosen should work - you will need a custom widget on the Page Template that will read the value of the custom field. The GetRelatedItems extension method of the page node should give you the document object that was selected.

    Having the document the widget will have to inject a link in the head of the page with the proper css attributes.