Re: [PHP] Dynamic HTML Creation
"Ramil Sagum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > given a template : > - > > User Information: > Name: {$name} > Address: {$address} > > - > and the php code: > > $smarty = new Smarty; > $smarty->assign('name', 'george smith'); > $smarty->assign('address', '45th & Harris'); > $smarty->display('index.tpl'); > I can do something very similar using DOM directly. Now that I have learned how to use DOM in PHP 5, it will (I hope) require just a few minutes to write some generalized functions to make things work in an equivalent manner. Doing things that way, the editor used to edit the UI can be virtually any HTML editor. My knowledge of the DOM and my code will be more portable to other languages. I am sure that Smarty can do many other useful things, but probably they are not needed for what I am doing. I think it is important to first learn the DOM and how to use it; it is a standard that can be used in an abundance of ways and in many other languages. Without becoming familiar with DOM it is difficult to understand the advantages of Smarty. You sent me a message offline from the newsgroup; I prefer to keep things in the list. You implied I am being ignorant. I try to avoid making emotional statements such as that. I tried to explain that I spend too much time learning things I can't use. It is not a matter of not wanting to learn; it is a matter of not wasting time. It is too easy for me to spend time learning something that I can't use. It is more a matter of having too great of a desire to learn. Since you are familiar with Smarty, it sure would help if you could explain it's advantage compared to using the DOM for what I am doing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
Sam Hobbs wrote: "Ramil Sagum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Ah. You should have said this in your first mail (which was confusing). It now becomes clear. I think what you are looking for is a template engine, like smarty http://smarty.php.net/ If Smarty is a good solution that the other osCommerce users and developers agree is useful, then yes, I should have said more in my original question. If however Smarty is not a good solution for osCommerce, then explaining that I am modifying osCommerce would have been confusing and distracting. I like the idea of separating the UI from the program. Programmers and software designers have been doing that for many years. It is usually easier to keep the UI separate from the processing and then have tags of some type in the UI that allows the processing to put data into the UI and pluck it out. That type of thing can be done using HTML too. There are some disadvantages of using HTML and the DOM but I suspect there are limitations of Smarty too. If it is possible to use HTML and the DOM then there are significant advantages to using an existing standard that is in common use. If a web site is hosted in a server owned by someone else and if the server's owner (which includes the employees) must install Smarty befor it can be used, then that is a critical disadvantage of Smarty. So do you know of specific advantages of Smarty compated to using the HTML and DOM standards? Without spending a lot of time to learn Smarty, it is difficult for me to see the advantages. Smarty is a template engine, you can download it and embed it in your application, it's not necessary to 'install' it on the server. I suggest you read some overview of Smarty, you'll get the idea really fast. It's easy to understand... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
"Ramil Sagum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Ah. You should have said this in your first mail (which was > confusing). It now becomes clear. I think what you are looking for is > a template engine, like smarty > > http://smarty.php.net/ If Smarty is a good solution that the other osCommerce users and developers agree is useful, then yes, I should have said more in my original question. If however Smarty is not a good solution for osCommerce, then explaining that I am modifying osCommerce would have been confusing and distracting. I like the idea of separating the UI from the program. Programmers and software designers have been doing that for many years. It is usually easier to keep the UI separate from the processing and then have tags of some type in the UI that allows the processing to put data into the UI and pluck it out. That type of thing can be done using HTML too. There are some disadvantages of using HTML and the DOM but I suspect there are limitations of Smarty too. If it is possible to use HTML and the DOM then there are significant advantages to using an existing standard that is in common use. If a web site is hosted in a server owned by someone else and if the server's owner (which includes the employees) must install Smarty befor it can be used, then that is a critical disadvantage of Smarty. So do you know of specific advantages of Smarty compated to using the HTML and DOM standards? Without spending a lot of time to learn Smarty, it is difficult for me to see the advantages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
On Sat, 28 Aug 2004 12:30:48 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote: > This is for osCommerce, which is a shopping cart system written in PHP. Many > of it's pages (the HTML) are not modifiable directly using a WYSIWYG editor, > which make the content difficult to modify, especially for non-technical > people. So what I can do is to make a page that is stored as a HTML page and > then in a separate PHP script add stuff (in this situation, it is left > and/or right menu columns) using the DOM. Since the system is written using > PHP, this improvement should also use PHP. I think PHP will do quite well > using it in this manner yet the system (osCommerce) can be easier to use. Ah. You should have said this in your first mail (which was confusing). It now becomes clear. I think what you are looking for is a template engine, like smarty http://smarty.php.net/ given a template : - User Information: Name: {$name} Address: {$address} - and the php code: $smarty = new Smarty; $smarty->assign('name', 'george smith'); $smarty->assign('address', '45th & Harris'); $smarty->display('index.tpl'); I think you can already see what this does. The non-technical people can edit the pages (as long as they leave the placemarkers for the output). The PHP-people can edit the code without worrying about the page layout (as long as the markers are there). I hope this helps. (code was taken from http://smarty.php.net/crashcourse.php) ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
I suppose it was too much to ask for some clearification. I hope someone else helps you. Good luck, by they way, the difference between VBScript and Javascript is monumental when using Gecko based browsers. Jason "Sam Hobbs" <[EMAIL PROTECTED]> wrote: > > Read the original question again; it is quite clear about the relevance to > PHP. > > > "Jason Davidson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > its possible to add HTML elements with DOM, im not sure what it has to > > do with php though? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
Read the original question again; it is quite clear about the relevance to PHP. "Jason Davidson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > its possible to add HTML elements with DOM, im not sure what it has to > do with php though? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
"Ramil Sagum" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Yes, it is possible. And you are right, PHP is a server side > language. In addition to PHP, > use a client-side scripting language (like JavaScript). JavaScript > also has functions for accessing the DOM (createElement and > getElementByID). I have used so many languages that for me the differences between VBScript and JavaScript is insignificant. Yes, I know that JavaScript will work too, essentially the same (for me) as VBScript. The question is not whether it cn be done using a non-PHP language; the question only is if it can be done using PHP. The answer is no; at least not using the design I asked about. At the time that PHP executes, the HTML is still incomplete, right? More specifically, the HTML document is not available (to PHP) to be accessed by the DOM. It is the document object that is a critical part of the design in my original question. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
"Justin Patrin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Fri, 27 Aug 2004 23:17:29 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote: > > Is it possible to use the DOM to add (HTML) elements to a page at the time > > the page is being shown? The HTML and VBScript shown below is a simplified > > version of what I need to do but of course I need to do it in PHP. Since PHP > > is server-side (right?) perhaps it is not possible. > > > > You're right, it's not possible. You'd have to create the whole page > with DOM and output it at the end. > > You may be able to use DOM to make a specific piece and inject it > You could always just use JavaScript to inject things as wel. Thank you. You understand the question. I am not sure of the details of what you were suggesting, but that is not important. The general idea is probably what I will do. This is for osCommerce, which is a shopping cart system written in PHP. Many of it's pages (the HTML) are not modifiable directly using a WYSIWYG editor, which make the content difficult to modify, especially for non-technical people. So what I can do is to make a page that is stored as a HTML page and then in a separate PHP script add stuff (in this situation, it is left and/or right menu columns) using the DOM. Since the system is written using PHP, this improvement should also use PHP. I think PHP will do quite well using it in this manner yet the system (osCommerce) can be easier to use. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
its possible to add HTML elements with DOM, im not sure what it has to do with php though? Jason "Sam Hobbs" <[EMAIL PROTECTED]> wrote: > > Is it possible to use the DOM to add (HTML) elements to a page at the time > the page is being shown? The HTML and VBScript shown below is a simplified > version of what I need to do but of course I need to do it in PHP. Since PHP > is server-side (right?) perhaps it is not possible. > > > > > Dynamic Table Demo > > > > Sub Window_Onload > Set NewRow = document.createElement("TR") > Set NewCell = document.createElement("TD") > NewCell.innerText = "Cell Text" > NewRow.appendChild NewCell > TableBody.appendChild NewRow > End Sub > > > > Dynamic Table Demo > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
On Fri, 27 Aug 2004 23:17:29 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote: > Is it possible to use the DOM to add (HTML) elements to a page at the time > the page is being shown? The HTML and VBScript shown below is a simplified > version of what I need to do but of course I need to do it in PHP. Since PHP is server-side (right?) perhaps it is not possible. --- Yes, it is possible. And you are right, PHP is a server side language. In addition to PHP, use a client-side scripting language (like JavaScript). JavaScript also has functions for accessing the DOM (createElement and getElementByID). HTH ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
On Fri, 27 Aug 2004 23:17:29 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote: > Is it possible to use the DOM to add (HTML) elements to a page at the time > the page is being shown? The HTML and VBScript shown below is a simplified > version of what I need to do but of course I need to do it in PHP. Since PHP > is server-side (right?) perhaps it is not possible. > You're right, it's not possible. You'd have to create the whole page with DOM and output it at the end. You may be able to use DOM to make a specific piece and inject it You could always just use JavaScript to inject things as wel. > > > Dynamic Table Demo > > > > Sub Window_Onload > Set NewRow = document.createElement("TR") > Set NewCell = document.createElement("TD") > NewCell.innerText = "Cell Text" > NewRow.appendChild NewCell > TableBody.appendChild NewRow > End Sub > > > > Dynamic Table Demo > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > !DSPAM:412fc78a52836398416238! > > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic HTML Creation
Is it possible to use the DOM to add (HTML) elements to a page at the time the page is being shown? The HTML and VBScript shown below is a simplified version of what I need to do but of course I need to do it in PHP. Since PHP is server-side (right?) perhaps it is not possible. Dynamic Table Demo Sub Window_Onload Set NewRow = document.createElement("TR") Set NewCell = document.createElement("TD") NewCell.innerText = "Cell Text" NewRow.appendChild NewCell TableBody.appendChild NewRow End Sub Dynamic Table Demo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php