【问题标题】:How to distinguish whether a page is published first time or multiple times in publish environment of Adobe CQ5Adobe CQ5发布环境如何区分页面是第一次发布还是多次发布
【发布时间】:2013-08-19 12:43:08
【问题描述】:

我需要在我的网站页面上显示的链接之外显示标签“新”和“更新”。

为此,我应用了检查版本数量的逻辑。如果版本数超过 2 我显示“更新”,否则我显示“新”。我能够在 Author 环境中实现它。

但是在发布环境中,为一个页面创建的版本数,即使该页面被修改和重新发布,也只有一个。那么如何确定页面是第一次发布还是多次发布。

【问题讨论】:

    标签: aem


    【解决方案1】:

    对此的一个建议是实现您自己的 servlet/listener 来监听复制事件。查看 EventHandler 和 JobProcessor 接口。例如,该 servlet 可以在组件实例上设置一个属性值,以便该组件可以在第一次显示时有所不同。它可能只是一个小的计数器变量,用于跟踪实际发布的次数或那里的一些更奇特的逻辑:)

    //imports
    
    @Service...
    @Component...
    @Property(name = "event.topics", value = ReplicationAction.EVENT_TOPIC)
    public class MyCustomEventHandler implements EventHandler, JobProcessor {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomEventHandler.class);
    
    @Override
    public void handleEvent(Event event) {
        LOGGER.info("Handling an event of some kind !!");
        process (event);
    }
    
    @Override
    public boolean process(Event event) {
        LOGGER.info("Processing an event !!");
        ReplicationAction action = ReplicationAction.fromEvent(event);
        if (action.getType().equals(ReplicationActionType.ACTIVATE)) {
            LOGGER.info("Processing an activation job, this is just what we are looking for !!!!!");
    
                //Logic for fetching/setting the properties you want from the component you want
                //goes here. Here you can make use of the action.getPath(); to get hold of the containing page
                //and then later on any specific components...
        }
        return true;
    }
    }
    

    要查看我的原始答案,请前往:http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__kbyb-i_need_to_displayla.html

    【讨论】:

      猜你喜欢
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多