Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my opinion, the best answer for your question is to implement a custom Resolver that would include the required Dynamic Component Presentations. I would be wary of doing anything when unpublishing, as sometimes you may want to keep the DCPs after unpublishing a given page (for "latest news" type of functionality or any other sort of dynamic queries), but the code sample below would make it simple for you to adapt if you need to unpublish all DCPs.</p> <p>Warning: Below code is not production-tested.</p> <pre class="lang-cs prettyprint-override"><code>using Tridion.ContentManager; using Tridion.ContentManager.CommunicationManagement; using Tridion.ContentManager.ContentManagement; using Tridion.ContentManager.Publishing; using Tridion.ContentManager.Publishing.Resolving; public class IncludeDynamicComponentPresentations : IResolver { public void Resolve( IdentifiableObject item, ResolveInstruction instruction, PublishContext context, Tridion.Collections.ISet&lt;ResolvedItem&gt; resolvedItems) { if (!(instruction.Purpose == ResolvePurpose.Publish || instruction.Purpose == ResolvePurpose.RePublish)) { // Do nothing more when unpublishing return; } Session session = item.Session; foreach (ResolvedItem resolvedItem in resolvedItems) { // Only do something if we're dealing with a page if (!(resolvedItem.Item is Page)) continue; Page page = (Page)resolvedItem.Item; if (page.ComponentPresentations.Count &gt; 0) { UsingItemsFilter filter = new UsingItemsFilter(session); filter.InRepository = page.ContextRepository; filter.ItemTypes = new[] { ItemType.ComponentTemplate }; foreach (ComponentPresentation cp in page.ComponentPresentations) { // Find all component templates linked to this component's schema Schema schema = cp.Component.Schema; foreach (ComponentTemplate ct in schema.GetUsingItems(filter)) { if (!ct.Id.Equals(cp.ComponentTemplate.Id)) { if (ct.IsRepositoryPublishable) { resolvedItems.Add(new ResolvedItem(cp.Component, ct)); } } } } } } } } </code></pre> <p>You would now need to add this to the GAC and modify [Tridion]\Config\Tridion.ContentManager.Config so this Resolver is called after every resolve action (under resolving/mappings for every item type).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload