开发者

CMS content editor / viewer

One of our users has decided that they need to be able to edit sections of content on our main website and I've been given the task of implementing it. The underlying model is that one or more divs in the page will have their content populated from a CMS.

To deliver the content I'm using an observer model to deliver content and this works fine. The page contains (at least) 3 server controls; data provider (CMS), controller (subject) and container (observer). The container will contain one of two content panels (edit or view) which will render on the screen appropriately with data pushed from the controller.

However, now I need to be able to switch between the editor and viewer panels (so changes can be previewed) and to be able to publish the edited content to the data provider (CMS) but I keep losing the edited content on the postback. I've attempted to override the 'SaveViewState' method but because the content panel is created after during the prerender (as it depends on a ViewState property), the control collection always shows the object that was created before (i.e. when the edit panel is being shown, the object in the control collection is the preview panel).

I don't want to go down the road of having both controls rendering for performance issues; I'm considering creating a tertiary component (probably a hidden field) that will store the edited text but was hoping someone on 开发者_运维百科here might have a better idea how to structure this?


Best bet would be to make the editor a separate page -- lumping it all together provides plenty of challenges, a bit of danger (how do you know the public can't edit it) and creates long term maintenance issues.


seems as you helped me may i make a suggestion:

have the normal view and the edit view on the page if the user is of correct userlevel.

have a button under the normal view that says edit, and a button under the edit view called preview.

when the preview button is clicked:

$(".previewbutt").live("click",function(){ code to update database and update div content });

the above code should be used to first submit the form

$.ajax({async:false, url:'',data:});

then do another call to get the content, update the normal display div, set editordiv to hidden

 $('.normalview').show('slow');
 $('.editor').hide('slow');

there will be a short animation but will cover all basis.

just an idea / option

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜