How do I shared content across templates in Sitefinity 5?

Posted by Community Admin on 03-Aug-2018 18:28

How do I shared content across templates in Sitefinity 5?

All Replies

Posted by Community Admin on 07-May-2012 00:00

I have multiple templates on a site. They all share the same footer which has content that needs to be editable by the content editor of the site. I cannot put the content in a master page because the site editor needs to be able to edit it through the WYSIWYG, but I don't want the editor to have to update it in multiple places when it needs to be updated.  I tried creating a shared content block, but apparently those are not accessible from templates unless I'm missing something. Is there a setting to turn on shared content blocks for templates? Thank you for your help.

Posted by Community Admin on 07-May-2012 00:00

Nancy,

Unfortunately I believe shared content blocks are not yet usable in templates. I know that the team is aware and looking ino this issue, I'll try to find out more and update this thread.

however, you may be able to fix this with a Sitefintiy base template. If you create a template in Sitefinity (under the design menu) and place a content block in this template, you can then create additional templates that use this as a base.

This way the base template will have a WYSIWYG editor, and any changes will automatically propagate to all templates that use it as a base.

hope this is helpful, thank you for your feedback!

Posted by Community Admin on 07-May-2012 00:00

I really wish they were available, but this will be an okay solution for this project. I can't use the same starter for my home and sub pages since they are too different, so I will still need 2 starter templates, but at least they will only have to update the footer content in 2 locations instead of multiple.

Posted by Community Admin on 07-May-2012 00:00

We created a widget that you can add to a template that can be used until the functionality is out-of-the-box. You can download the widget from here. Just add it to your project, re-compile, and then add it to your page controls.

It just allows you to select a content item to be displayed on your template. You have to go to the content section to edit it your "Content block", but once edited, it will update on the template.

Posted by Community Admin on 07-May-2012 00:00

Two more things. First, I get a 404 when I click the link to download the widget. Second, once I get it downloaded, what do I need to do to "add it to the project"? Is it just a matter of putting the file(s) in a certain folder or do I need to edit a config file as well? I do have Visual Studio and I know where the build button is but that is about as far as my knowledge goes. I am learning as I go on this project.  Feel free to point me to documentation for this. I am new to Sitefinity and .net so I don't know all of this. Thanks again for your help.

Posted by Community Admin on 07-May-2012 00:00

I apologize for the link. Most of the time, chrome copies the protocol also. (link updated)

As for where to put the archived folder, that is up to you. We keep all of our internal widgets in a "Widgets" folder on the root of the site. Once you have the folder extracted, open up your project. Then, with the "Show All Files" set, right click on the new folder and include it in your project. Then you should just be able to build your project. There is an icon next to the "Refresh" icon above your solution explorer. Here is a link to a site that has an image of the icon.

As for registering the control, you need to follow this document to add to the "PageControls". Below are the only values you need to enter for the fields that match the image at step 5:
ControlType: ~/Widgets/SharedContent/SharedContentWidget.ascx
Name: SharedContent
Title: Shared Content
Description: Control to display a content block on the site.
LayoutTemplate: (leave blank)
VisibilityMode: None

The control type assumes that you have extracted the SharedContent folder in a folder called Widgets. This folder would be in the root of the site files. I attached a screen shot of the settings section with the widget already registered.

Once the widget is registered, you can then just navigate to your page template and you should have a "Shared Content" widget under the content section on the right. If you created a new section then it will be under that new section rather than the "Content" section. If you do not see the widget then you might need to reset your site. You can do this by making a fake edit to your web.config file. (Just delete a character and then type it back. Then save the file)

I hope this helps you out.

Posted by Community Admin on 07-May-2012 00:00

Richard, thank you for sharing this solution and for your help with this thread!

I just wanted to add a quick shout-out for Sitefinity Thunder: http://www.sitefinity.com/sitefinity-thunder

Nancy, if you're new to Sitefinity, the Thunder visual studio extension helps minimize the guesswork. It has a feature to quickly register widgets in your solution into the toolbox and lots of other time savers and helpers.

For a more thorough walkthrough be sure to check out the recording of the recent webinar on thunder: http://www.sitefinity.com/blogs/joshmorales/posts/12-04-19/sitefinity_thunder_webinar_notes.aspx

Posted by Community Admin on 08-May-2012 00:00

Thank you so much. this is exactly what we needed. I really appreciate your help and you quick response time. I will take a look at Sitefinity Thunder as well.

This thread is closed