Shared Content in Page Templates

Posted by Community Admin on 04-Aug-2018 04:52

Shared Content in Page Templates

All Replies

Posted by Community Admin on 20-Jun-2012 00:00
Hi Team Telerik,

How do we add shared content to Page Templates?

Regards,
Siddesh Kapadi
Posted by Community Admin on 20-Jun-2012 00:00
Siddesh,

Here's a blog post on a work around that will enable this functionality.
Posted by Community Admin on 20-Jun-2012 00:00
Also, don't forget to vote for the issue in PITS (lot of good that does anyway, it's already the top voted item by 23 ahead of #2) :/

**EDIT** Link
Posted by Community Admin on 26-Jul-2012 00:00
Hello,

Although it initially appears that solutions works. When you actually try to edit the shared content, the changes are NOT reflected on all the templates using that shared content. Does anybody else have a workaround or suggestion?
Posted by Community Admin on 26-Jul-2012 00:00
Lee,

I believe you'll need to republish the template that the content block is on. Until you do that, the change won't take hold.
Posted by Community Admin on 26-Jul-2012 00:00
Thanks for the reply Tim,

I tried that. I have 2 templates that are using shared content blocks. When I edit a shared content block on one template and publish it will work for that template. However, the changes are not reflected on the other template that is using that shared content block, even if I republish.
Posted by Community Admin on 26-Jul-2012 00:00
That's sounds right and it's the major downfall of using this method. You'll need to publish each template that you're using the content block on.

We've switched to using code to pull in a specific content block and place the content on the page with an asp:Literal. That way, we don't have to worry about issues with using the work around.
Posted by Community Admin on 23-Oct-2012 00:00
Resurrecting this thread and I'll summon Jochem and Steve to argue with me.  ;)

We have templates, and templates can inherit from other templates.  So, for example, if you had a footer that was common to the entire site you could put that into a template and then create numerous sub-templates based off that original template.  This essentially creates "shared content" - content that is shared amongst numerous templates and the entire website.

With 124 votes this is obviously a big issue (and perhaps that is reason enough), but I'd love to understand a bit more about the use cases everyone is looking to tackle with shared content.

Thanks,

Gabe Sumner
Telerik | Sitefinity CMS


Posted by Community Admin on 24-Oct-2012 00:00
Hey Gabe,

Well there's not much of an argument, you're right its a big issue and Tim's right that its 'broken'  :)

---
1. Create a masterpage called 'parent' and put a content block in the footer and a menu in the header.
2. Create 5 masterpages which inherit from 'parent' and name them 1-5 and put a content block in the body to identify them.
3. Create 6 pages, each one utilizing one of the templates.
4. browse all 6 pages.
---

Everything works as you'd expect it, the footer content block appears on all the pages correctly.
Now edit the 'parent' masterpage and change the content block and hit publish.

If you browse all the pages again, you'll see 5 pages still showing the old content, and just one (the one utilizing the parent masterpage) showing the new content. Meaning I'd have to re-open and re-publish every inherited masterpage to get the changes reflected.

At least that was the issue right up until 5.1.3270 where I last tried it :) Nice sneaky fix there :) But unfortunately .Master changes aren't reflected upon the inherited ones still.


But that's only one third of the problem, the second part of the problem lies in the content-abilities of content blocks.

Although both are html-field only by design their functionality is different.
A template content block, is sort of a 'strict' html-field, where it strips out spans and only stores xhtml valid markup.
Where as a page or shared content-block can store html5 valid markup and doesn't strip out spans.

(FYI: The ability to set which contentfilters apply to a contentblock is broken atm)

Why is this important?

Let's take an actual example of displaying a company's address. Since its 2012 we want to mark-up our address with some microdata.

<div itemscope itemtype="schema.org/Organization">
  <span itemprop="name">Google.org (GOOG)</span>

Contact Details:
  <div itemprop="address" itemscope itemtype="schema.org/PostalAddress">
    Main address:
      <span itemprop="streetAddress">38 avenue de l'Opera</span>
      <span itemprop="postalCode">F-75002</span>
      <span itemprop="addressLocality">Paris, France</span>
    ,
  </div>
</div>


The thing is, you simply can't. Copy-paste that on a template editor and it won't store it and strips out in a weird fashion.
Truthfully, the only idiotic way to re-use a marked-up address is to write a usercontrol with that as the markup, save that as a widget and then drag-n-drop it on the templates.

Here's a quote from a support ticket: 
"...but the instance of HtmlField in page tempaltes is not affected by the mapped template it will always remain the default html field in sitefinity. This is behaviour done by design as the html field in templates shouldn`t be customized "

Meaning by design, we're working with a CMS system that forces us to adhere to a 1999 (yes more than a decade ago and in the previous century) standard.


And the third issue with inherited templates vs shared content is perhaps not so much technical as it is permission related.

Sometimes you simply don't want to allow certain users to have template editing capabilities. 
But when they should be able to edit a certain re-appearing content block say some quote/announcement/banner you have to compromise.

Either you take the risk and hope every day that a novice user won't remove or accidently drop something on a template. 
Or you don't take the risk and force the client to drag-n-drop that content block on every single page (s)he creates.

Posted by Community Admin on 24-Oct-2012 00:00
I also like to push this issue. I won't go back to the times where we were promised that it would be there after a few releases...!?!

I used this option all the time in the 3.7 sites, and also my experience with clients is that they like this option.

Some content  you just have to copy/paste from your HTML into your templates. It's not worth creating widgets for that (as Jochem mentioned).

So, really hope this will be in the next version as you would make much clients happy.

In the meantime if someone needs a simple workaround, check this blogpost:

www.danielplomp.com/.../sitefinity-'shared-content-selector'---part-1

As it would maybe help to make life easier :)

---
Daniel
Posted by Community Admin on 01-Nov-2012 00:00
I'll join the argument "For" shared content blocks on templates, but from a different angle.  One that should always be utmost in our thoughts: Our large corporate clients.

For these clients, we provide a very locked down experience with permissions, workflows, access restrictions very strict.

Giving users the ability to change Page Templates is generally not something that we do, as they can break the whole site in this way.

But sometimes we want to allow them to change one small section (ContentBlock) on the template.

Right now, we can't (easily), as they can't see "Design -> Page Templates" due to permissions.

However, we can easily allow then to see "Content -> Content Blocks" where they could interact with the shared content block, and therefore update only that part of the template we allow them to.

Hope that makes sense, and adds another angle as to why we should allow shared content blocks on templates.
Posted by Community Admin on 10-Jan-2013 00:00
Hey everyone, Sitefinity 5.3 adds support for shared content blocks in page templates. Feel free to review the release notes.
This thread is closed