1

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

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

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

4

1 回答 1

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

于 2013-08-27T07:12:41.717 回答