CMS 内容编辑器/查看器
我们的一位用户决定他们需要能够编辑我们主网站上的内容部分,我被赋予了实现它的任务。底层模型是页面中的一个或多个 div 的内容将从 CMS 填充。
为了交付内容,我使用观察者模型来交付内容,效果很好。该页面包含(至少)3个服务器控件;数据提供者(CMS)、控制者(主体)和容器(观察者)。该容器将包含两个内容面板(编辑或查看)之一,这些面板将根据从控制器推送的数据适当地在屏幕上呈现。
但是,现在我需要能够在编辑器和查看器面板之间切换(以便可以预览更改),并且能够将编辑的内容发布到数据提供程序 (CMS),但我在回发时不断丢失编辑的内容。我尝试重写“SaveViewState”方法,但由于内容面板是在预渲染期间创建的(因为它取决于 ViewState 属性),因此控件集合始终显示之前创建的对象(即,当编辑面板为如图所示,控件集合中的对象是预览面板)。
我不想因为性能问题而让两个控件都渲染;我正在考虑创建一个第三级组件(可能是隐藏字段)来存储编辑后的文本,但希望这里的人可能有更好的想法如何构建它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的选择是让编辑器成为一个单独的页面——将它们集中在一起会带来很多挑战,还有一点危险(你怎么知道公众无法编辑它)并产生长期维护问题。
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.
看来你帮助了我,我可以提出一个建议:
如果用户具有正确的用户级别,则在页面上拥有正常视图和编辑视图。
在普通视图下有一个名为“编辑”的按钮,在编辑视图下有一个名为“预览”的按钮。
当单击预览按钮时:
上面的代码应该用于首先提交表单,
然后再次调用以获取内容,更新正常显示的div,将editordiv设置为隐藏,
将会有一个简短的动画,但会覆盖所有基础。
只是一个想法/选择
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:
the above code should be used to first submit the form
then do another call to get the content, update the normal display div, set editordiv to hidden
there will be a short animation but will cover all basis.
just an idea / option