Widgets inside the Zend Framework - Where should they go?

I have been working with the Zend Framework for a long time (using Doctrine as an ORM) and have done several projects with it.

In several upcoming projects, I need widgets to be similar to how Wordpress does them. You have a post / page that might look like this:

Subscribe to my newsletter:
[subscribe/]

View my events
[events limit=5 sort=date/]

View this page comments
[comments/]

Where they say that the subscription widget will be replaced with Blog :: subscribeWidget, and events can be replaced with Events :: eventsWidget, etc.

Now he has done my head in the last few weeks about how I do this? I came up with the following options:

  • I can place widgets inside controllers and then name them as actions. The problem here is that the code can fly between controllers, and I read that it is expensive due to the number of shipments.

  • . , $this- > renderPage ($ Page), . , , -, , , , , ?

  • - ? ?

, :

  • , , ..

  • , ajax , # 2 ( ), ?

+3
2

, .

:

Content; with methods: render, renderWidgets, renderWidget, renderCommentsWidget (comments).
Event; with methods: renderEventsWidget (many events), renderEventWidget (one event)
Subscription; with methods: renderSubscribeWidget (subscription form).

:

app.widgets.comments.helper = content
app.widgets.subscribe.helper = subscription
app.widgets.events.helper = event

:

Content for use for all pages.
Event for use for all events.
Subcriber for use for subscriptions to content

, - : echo $this->content()->render($this->Content)

Content:: render() -, , Content:: renderWidgets(). app.widgets, bbcode ( 'render'.ucfirst($ tag).' Widget '). , , Content:: renderCommentsWidget() .

, . ContentCommentsWidget View Helper. .

, AJAX, . , , ajax. . , - . , .

, - , - , . , , .

.


Update:

:

  • BalCMS - CMS, /application/modules/balcms/view/helpers /application/modules/config/application/balcms.yaml
  • BalPHP - , /lib/Bal/View/Helper/Widget. PHP
0

, , , .. , , .. HTML, ; Action View Helper .

, , , AJAX , . JavaScript , , Head Script Helper / .

+5

Source: https://habr.com/ru/post/1719206/


All Articles