Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

We have a requirement to have a component (exactly 1) mandatory on a page.

Say, admin user has created a page and then no other user can edit-save that page without one of that component on that page.

enter image description here

share|improve this question
4  
Since you seem to be using XPM, I would suggest to use pagetypes and regions for this. Make the CP required in that region to prevent users from deleting it. –  Albert Romkes Jul 18 at 9:03
    
A 1:1 requirement suggests this presentation belongs with a given "page type" (small "p," as in the concept). If you have other components that represent Web page (e.g. SEO data) you could link to this there instead, otherwise you might add it via the page template. Whatever approach you use, consider basing it on configurable prototypes--that way you can handle new requirements through page and content changes rather than (just) code. –  Alvin Reyes Jul 20 at 17:43

3 Answers 3

No such out of the box functionality is available and Event system is one of the way to achieve it. You may write a custom event system code to achieve this on Page Save event.

share|improve this answer

If the component is a mandatory feature of the page, then your template should take care of this. If it's truly mandatory, why make it manageable?

This should simply be a question of invoking RenderComponentPresentation with the component and template ids as parameters. To make this maintainable, I'd suggest passing the webdav urls of the component and template as parameters to your template building block.

If you need to allow it to be managed, then the correct approach is to use the events system to check for conformance when the page is saved.

share|improve this answer
    
Nice thought Dom :) –  Pankaj Gaur Jul 21 at 3:42
    
Nice answer Dom. However, when @Saurabh said "...without one of that component on that page.", I think that he meant "... without one Component, based on a specific Schema, on that Page." –  Jonathan Williams Jul 21 at 7:10
    
@JonathanWilliams - sure, well in that case, as I said, the events system is the way to go. –  Dominic Cronin Jul 21 at 7:29

In addition to Pankaj's answer, the Tridion GUI is also extensible and it maybe possible to extend the Page View such that based on some criteria (the chosen page template perhaps), a Component Presentation is added.

This may require going deep in to the GUI Extension framework - no mean feat!

Alexander's site is a pretty useful resource - http://tridion.uibeardcore.com/

share|improve this answer
2  
Whenever you need to validate something in a data model, consider it mandatory to perform the validation on the server and optional to perform it on the client. The reason for this is that not every user may use your client application and some users may actively work around your client-side validation. So any validation you do in the client may be bypassed. In the Tridion case for example anyone writing code using the Core Service will not trigger your Anguilla validation, while they will actually trigger the event system's validation. –  Frank van Puffelen Jul 18 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.