如何在Adobe CQ5的发布环境中区分页面是第一次还是多次发布

时间:2013-08-19 12:43:08

标签: cq5

我需要显示标签" New"和"更新"除了我网站页面上显示的链接。

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

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

1 个答案:

答案 0 :(得分: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