Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bamajr

Pages: [1]
1
The Smarty system itself is part of the business logic, and probably could be put its own libs directory (I think that is where the example puts it.) The templates that contain the content (foo.tpl) could go in the views folder, or in the Smarty templates dir, whichever works better for you. I think in my implementation I ended up using the Smart templates folder for the templates so I would know they are Smarty templates and not default TinyMVC view files. It really doesn't matter technically, its whatever works for your implementation.

I understand that TinyMVC was build to run as a stand-alone MVC, so there isn't a designated spot for Smarty. However, it seems to me, if one was designed for the other, there would be a clear, concise method of implementation, instructions, defining why, and examples.

Here, I'm being told Smarty is business logic, which tells me it should be part of the Model, except for the templates (I.E. index.tpl, header.tpl, footer.tpl and etc.), which are view elements.

[edit] to add, Smarty basically replaces the TinyMVC views. So instead of $this->load->view() you use $this->smarty->display(). They both load and display a template, but TinyMVC views are just plain PHP files and Smarty views are the Smarty templates.

Here I'm being told Smarty replaces the TinyMVC views.

Realistically, Smarty is all three pieces of the MVC. So, from an organization standpoint and in an effort to sustain some sort of structure, Smarty should be hacked up and put into corresponding directories.  :o

This is what I'm getting at. MVC has no standard. It is a development theory, not a development structure. Software/Web developers are classified into groups, based on their interpretation of MVC. A framework is then built to put structure to each groups interpretation of MVC. Thus, the reason there are so many application frameworks, supposedly based on MVC, for people to choose from (I.E. Struts, Zend, Cake, Tiny and others).

TinyMVC is a MVC application framework for PHP, based on one person's (or a group of people) interpretation of MVC. It is my understanding, the person who built Smarty also built TinyMVC. Yet the idea of how Smarty and TinyMVC should integrate, isn't clear.

As a solution, why not release a TinyMVC download package, which has a working instance of the latest version of Smarty in it? Seeing the two working together is way easier to understand, than references to code, without file names, file names which do not coincide and references to MVC elements without a clearly defined structure.

2
agreed, MVC definition is all over the map, and doesn't even resemble its original roots.

Very true!

This is an interesting read. http://aspiringcraftsman.com/2007/08/25/interactive-application-architecture/

Good article...

As far as TinyMVC goes, it loosely follows a typical web MVC pattern of Model (database) View (templates) and Controller (Business logic glueing them together.)

Okay, so now we're getting somewhere.

In the article you mentioned above, it talks about the The Model-View-Controller Pattern for Web Applications:

Quote
the View is the content (generally HTML and associated client-side script) returned to the Web client. Depending on the implementation, Views may be text-based templates which are rendered by a view processor, or they may be objects compiled from templates which encapsulate the content to be rendered.

By this definition, shouldn't Smarty as a templating engine, reside in /tinymvc/myapp/views/ or at the very least be called by the view process? While using Smarty with TinyMVC, isn't Smarty a sub-system of the view process?

Yet on page http://www.tinymvc.com/documentation/index.php/Documentation:Templates there is a file created called tinymvc_library_smarty_wrapper.php which is the only file in the TinyMVC framework, which references where visual elements, contained by Smarty, are located. However this file is put in the /tinymvc/myapp/plugins/ directory instead of the /tinymvc/myapp/views/ directory. What would a website/web-app developer, who is using Smarty, put in the "view" directory, if not the Smarty system (or a call to the Smarty system) itself?

3
Quote
I have read the TinyMVC documentation for managing controllers and how to add Smarty. However, the documentation seems incomplete or, at the very least, confusing. How can the page contents be in the TinyMVC /controller/ directory and the Smarty /templates/ directory at the same time? Seems to me, Smarty .TPL files will contain the page contents, but also contain view elements. What am I missing here?

The /controller/ files (ideally) should not contain any content, they just control what view file is displayed and what content is assigned to the view. The /controllers/ part of the documentation just shows a crude example of how a controller works without the integration of views quite yet. A more complete example is in the /views/ section of the docs.

http://tinymvc.com/documentation/index.php/Documentation:Views

Also, see the section of the documentation where Smarty templates are integrated.

http://tinymvc.com/documentation/index.php/Documentation:Templates

[edit] I added a comment to the controller docs to make this clear.

Thanks for your responses. I guess my confusion is a little deeper than my questions, so I'll see if I can make myself more clear.

I understand MVC as a concept, though I've seen so many people talk about MVC without actually having a firm grasp of where things fit. MVC becomes useless when there isn't a standard, across the board, which is followed by everyone. The only standard is what the letters stand for, which is pretty much why I do my absolute best to stay away from MVC.

I often laugh at developers who preach MVC and code in Java, C# or .NET, because their MVC implementations make their websites and/or web-based applications slow and clunky. I could make the same websites and/or web-based applications, with HTML, CSS, and PHP (maybe even through in some JavaScript and jQuery) perform much faster and much more efficiently.

With a simple, one page website, one could argue, HTML is text to communicate information to the reader, making HTML the Model. On these grounds, it could also be argued CSS shapes the HTML, by adding visual style to the content, separate, but not completely, independent of the HTML... making CSS the View. With HTML as the Model and CSS as the View, the web browser would be the controller, as it combines and renders the HTML and CSS into a set of pixels on a screen. A web browser provides the UI for basic I/O and we can use a different browser to get comparable results, though one browser may render the HTML/CSS faster, with more finesse, or with more bells and whistles.

This may be MVC, in its basic form, but definitely not its only form, as it relates to websites and/or web-based applications. In my world, I deal strictly with websites and web-based applications in LAMP/MAMP stacks. Here, classes to store and manipulate data (or states), typically from within a database of some kind would be considered the Model. Any/All SQL/MySQL connections and functions would fit in as a part of the Model. The View would be any pieces creating the website's and/or web-based application's UI (in this case, HTML and CSS) necessary to render the model to the user. PHP would be the controller, as it determines what input was provided, how the model will change as a result of that input, and what view should be provided as a result. If this were entirely accurate, Smarty would be it's own MVC.

I can see how Smarty, as a template engine, could be either view or controller. I can even see how someone could identify Smarty as the UI, for I/O of the Controller, so that it exist, in an MVC environment, and is not a part of either model, view or controller.

So, when I say I'm confused about the documentation about how to integrate Smarty, my confusion stems from the many varieties of MVC implementation ideas.

I'm just not sure the "Documentation:Templates" identifies the intent on how Smarty should integrate.

4
Here is some answers hopefully :)

1. The demo comes with some useful plugin examples for different kinds of template resources. You don't need to move them to the Smarty plugins unless you intend on using them.

Okay... I'm not sure I'll use them, but I'm going to save them anyway, and get rid of the remaining demo files.

2. TinyMVC has plugin dir, Smarty has a plugin dir, they are incompatible and serve different purposes. Do not mix the plugins together.

I did keep them separate, suspecting this was the case. Many web-based systems can run on top of each other, and any number of them could use or require these types of directories.

3. All browser accessible files (js, css, images, etc.) should reside under the HTML document root. It is completely up to you how to organize these files.

Okay... Again, this is what I assumed. This is how I handled these directories with stand-alone Smarty installations.

4. TinyMVC is  a framework where controllers handle the page contents, not stand alone index.php files. This framework has its own directory structure for managing the controllers. Follow the TinyMVC documentation for managing controllers and adding Smarty to the mix. There is a complete explanation for Smarty integration.

I have read the TinyMVC documentation for managing controllers and how to add Smarty. However, the documentation seems incomplete or, at the very least, confusing. How can the page contents be in the TinyMVC /controller/ directory and the Smarty /templates/ directory at the same time? Seems to me, Smarty .TPL files will contain the page contents, but also contain view elements. What am I missing here?

5. There is a setPluginsDir() setting, see the Smarty manual. By default it looks in the Smarty folder (typically in libs). /libs/ itself is not settable from Smarty, this is just where the Smarty library files reside. Decide where you want them and include them appropriately.

I've always used the /libs/plugins/ directory for other Smarty installations, so the default is fine.

5
Coding - Application Development / Confusion using Smarty with TinyMVC
« on: March 01, 2012, 03:07:15 pm »
Hey Y'all!
Yes, I'm new to this forum... No, I'm not new to TinyMVC or Smarty. I've been using them independently of each other for a while (Smarty longer than TinyMVC).

I'm now working on a project, where I want to use TinyMVC and Smarty, but I'm having problems getting it set up correctly. I started by installing TinyMVC and I can successfully see the "Welcome to TinyMVC!" landing page (http://nacits.com/ if you want to see it too).

Here are some things that a person may need to know:

  • I'm using a virtualHost system. The path to each website is ~/home/domain/public_html/ so this particular site is ~/home/nacits/public_html/
  • TinyMVC is installed at ~/home/nacits/tinymvc/
  • The index.php file for the TinyMVC "Welcome to TinyMVC!" landing page is located at ~/home/nacits/public_html/ (and it works!)
  • Smarty is installed at ~/home/nacits/smarty/

Questions:
  • With any new download of Smarty, there is a Demo included. The demo has several plugins in the ~/home/nacits/smarty/demo/plugins/ directory which are not included in the main ~/home/nacits/smarty/libs/plugins/ directory of the smarty system. Why? When I'm done with the Demo, should I move the Demo Plugins to the main ~/home/nacits/smarty/libs/plugins/ directory of the smarty system?
  • TinyMVC also has a plugins directory located at ~/home/nacits/tinymvc/myapp/plugins/ should all the smarty plugins be moved from the main ~/home/nacits/smarty/libs/plugins/ directory of the smarty system to the main ~/home/nacits/tinymvc/myapp/plugins/ directory of the TinyMVC system?
  • Many web-devs use a /libs directory for things like JavaScript, jQuery and etc., for basic web sites. Where does one recommend these files go, in a TinyMVC/Smarty system? Why? What about images, flash objects and other multimedia?
  • The documentation at http://www.tinymvc.com/documentation/index.php/Documentation:Templates suggests creating two files (myapp/plugins/tinymvc_library_smarty_wrapper.php and myapp/controllers/hello.php). The hello.php file looks pretty similar to Smarty's index.php file. Should the code from hello.php actually be in Smarty's index.php file? Generally, Smarty's index.php file would reside at ~/home/nacits/public_html/index.php but the TinyMVC documentation suggest the hello.php file be located at ~/home/nacits/tinymvc/myapp/controllers/hello.php
[li]That same page of the documentation demonstrates how to tell Smarty where its pieces are located.
[/li][/list]
Code: [Select]
parent::__construct();
    $this->setTemplateDir('/var/smarty/templates/');
    $this->setCompileDir('/var/smarty/templates_c/');
    $this->setConfigDir('/var/smarty/configs/');
    $this->setCacheDir('/var/smarty/cache/');

Given the paths I defined in my first list, above, should my assignments be:

Code: [Select]
parent::__construct();
    $this->setTemplateDir('/smarty/templates/');
    $this->setCompileDir('/smarty/templates_c/');
    $this->setConfigDir('/smarty/configs/');
    $this->setCacheDir('/smarty/cache/');

or...

Code: [Select]
parent::__construct();
    $this->setTemplateDir('../smarty/templates/');
    $this->setCompileDir('../smarty/templates_c/');
    $this->setConfigDir('../smarty/configs/');
    $this->setCacheDir('../smarty/cache/');
    and...

    why isn't there a libs and/or plugins assignment in this code?[/li]

I have the front-end web design created and laid out, using HTML5, CSS3 and jQuery. I'm bound by a timeline and ready to move the site's front-end code, into Smarty's template structure. Content will then be added by multiple people and development of back-end functionality (PHP/MySQL) will be done by a separate group. This is all in motion, and we have some things ready to go, but, I'm stuck trying to get TinyMVC and Smarty working together.

Can anyone offer any help?

Pages: [1]