Page 1 of 2

Web Parts in PHP

Posted: Mon Mar 26, 2007 7:57 am
by fastfingertips
Hello

Does anyone tried to develop applications using web parts (like in ASP.NET)? I'm interested to find out about this subject and also about the architectural solution that you've found.

Posted: Mon Mar 26, 2007 9:07 am
by feyd
web.. parts?

Posted: Mon Mar 26, 2007 9:22 am
by fastfingertips
Yes you can see your site as a puzzle a web part is a piece of a puzzle, the important thing is that you can assemble this pieces as you need and in the order you need.

Posted: Mon Mar 26, 2007 9:29 am
by feyd
They are often called components or modules in many circles outside of Microsoft.

Posted: Fri Mar 30, 2007 3:16 am
by fastfingertips
Name it as you want :D

I called them like that just to get a better hint to my problem, since i'm afraid that the modules may not be the best description to it.

Posted: Fri Mar 30, 2007 3:21 am
by Maugrim_The_Reaper
Maybe if you described a specific scenario? When building application, adding modular pieces can be solved via a number of solutions depending on what the pieces are aimed at doing. For example, if I posted a article to a blog I might have a collection of modules/plugins to filter that article before saving it (maybe applying markup, escaping special characters, highlighting code syntax). The solution for this setup could differ from your particular case obviously.

Posted: Fri Mar 30, 2007 10:58 am
by RobertGonzalez
What are you trying to do?

Posted: Fri Mar 30, 2007 12:18 pm
by Christopher
Perhaps you could provide some links to examples of "web parts (like in ASP.NET)" so we can understand the concept better.

The details

Posted: Mon Apr 02, 2007 7:17 am
by fastfingertips
I will start my explanation with an example, i hope in this way i will be better understood.

In a shopping cart for example i have product page details where i present to the user the details of the product that he wants to buy it. In the bottom page i have something like "Related products". This module is independent from the rest of the page with only one exception: the products listed in that area are from the same category with the product for which i'm displaying the details.

So my problem is that i have a page catalog where i should record the modules and their order, but some modules must communicate with others.

All this functionality must be provided in a very flexible enviroment (i have different templates for each language etc).

Posted: Mon Apr 02, 2007 9:04 am
by Begby
Have you looked into something like smarty? It would let you create and reuse templates that you can include in other templates quite easily and pass arguments too.

Like this

Code: Select all


<p>
Here is my product detail:
{$product.name}<br />
{$product.price}<br />
{$product.description}<br />
</p>

<p>
Here are the related items:
{include file='tpl/related_items' category=$product.categoryID}
</p>


Posted: Mon Apr 02, 2007 9:10 am
by fastfingertips
I'm using a mixed solution of Zend and Smarty but what you wrote isn't help me to much, i was concerning about architecture not on how to implement different templates, but how to make a flexible dialog system between my modules.

Posted: Mon Apr 02, 2007 9:19 am
by Begby
I think each of the modules you are describing are a view. It should be up to the controller to get the data and then create and call each view and pass the view the correct information, not a matter of the views (modules) talking to each other. I think getting your modules to talk to each other is not necessarily a good idea.

So in this case your controller would compile a list of products and category IDs from the model, create a partial view for the cart detail using the products, create a partial view for the related products by passing it the product IDs, then combine the two into one final view and paint it.

The language part should probably be encapsulated into the views. Each view as it renders itself would pull the language data either based on some sort of configuration setting or a language indicator passed to it by the controller.

Posted: Mon Apr 02, 2007 9:28 am
by fastfingertips
Each module has it's own view and each module should call it's view to render itself the problem is that i'm not sure on the solution to make these modules to communicate dynamically, the what is called Connection Zone.

Re: The details

Posted: Mon Apr 02, 2007 11:56 am
by Christopher
fastfingertips wrote:In a shopping cart for example i have product page details where i present to the user the details of the product that he wants to buy it. In the bottom page i have something like "Related products". This module is independent from the rest of the page with only one exception: the products listed in that area are from the same category with the product for which i'm displaying the details.

So my problem is that i have a page catalog where i should record the modules and their order, but some modules must communicate with others.
It sounds like you want multiple Model/View pairs. Each Model would be initialized with a "category" value from the request/session/etc. All of these sub-Views would render into a main or outer View.
fastfingertips wrote:All this functionality must be provided in a very flexible enviroment (i have different templates for each language etc).
A "flexible environment" is a very subjective term. Every programmer thinks their own or favorite framework is the most "flexible environment." Can you be specific about what "flexible environment" means to you?

Posted: Mon Apr 02, 2007 6:44 pm
by wei
Is this what you are refering to?

http://msdn2.microsoft.com/en-us/library/hhy9ewf1.aspx
ASP.NET Web Parts is an integrated set of controls for creating Web sites that enable end users to modify the content, appearance, and behavior of Web pages directly from a browser. The modifications can be applied to all users on the site or to individual users. When users modify pages and controls, the settings can be saved to retain a user's personal preferences across future browser sessions, a feature called personalization.