Web Parts in PHP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Web Parts in PHP

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

web.. parts?
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

They are often called components or modules in many circles outside of Microsoft.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What are you trying to do?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Perhaps you could provide some links to examples of "web parts (like in ASP.NET)" so we can understand the concept better.
(#10850)
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

The details

Post 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).
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post 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>

fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post 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.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post 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.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: The details

Post 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?
(#10850)
wei
Forum Contributor
Posts: 140
Joined: Wed Jul 12, 2006 12:18 am

Post 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.
Post Reply