php-general Digest 8 Jul 2007 07:00:55 -0000 Issue 4891

Topics (messages 258461 through 258465):

Re: About PHP CMS
        258461 by: Nathan Nobbe
        258462 by: Nathan Nobbe
        258463 by: Nathan Nobbe
        258464 by: Anton C. Swartz IV

About DOM function in PHP
        258465 by: Kelvin Park

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
forgot to copy the list on this one, sorry

---------- Forwarded message ----------
From: Nathan Nobbe <[EMAIL PROTECTED]>
Date: Jul 7, 2007 2:13 PM
Subject: Re: [PHP] About PHP CMS
To: Kelvin Park <[EMAIL PROTECTED]>

On 7/7/07, Kelvin Park <[EMAIL PROTECTED]> wrote:
Can XSLT be used to separate CSS/XHTML/PHP/AJAX completely?
yes

XSLT is used to map one set of XML to another set of XML, thats what the
transform is all about.
ive only been working with it for a while so im not that good yet, but what
i do is build up XML data in
PHP; that XML maps to points in an xsl file.  then i use the PHP XSLT
functions <http://www.php.net/manual/en/ref.xslt.php> to render XHTML
by combining the XML data and the xsl file.  the XHTML is what gets sent to
the browser via echo.
you can use tools in PHP like SimpleXML and DOM to build up an XML
document.  i can send you a sample
if youd like.

also, if you want to separate javascript from PHP and XHTML thats really a
different issue.  in order to do that
you need to link in javascript externally via the <script> tag instead of
using inline scripts.  you may want to
look at some frameworks like prototype <http://www.prototypejs.org/>,
scriptaculous <http://script.aculo.us/> and jquery <http://jquery.com/>.
but that is another universe altogether.

-nathan


On 7/7/07, Kelvin Park < [EMAIL PROTECTED]> wrote:

Can XSLT be used to separate CSS/XHTML/PHP/AJAX completely?
Do you use XSLT with XHTML on a same file?
It seems like XSLT is derived from XML.

On 7/7/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> to keep html separate from php you can also look at XSLT.
> ive heard good and bad things about smarty.
>
> -nathan
>
> On 7/6/07, Davi < [EMAIL PROTECTED] > wrote:
> >
> > Em Sexta 06 Julho 2007 21:24, Kelvin Park escreveu:
> > > Is it possible to have PHP code completely separate from the HTML
> page
> > that
> > > needs to be completely dynamic? (That's how ASP.NET sort of works I
> > think).
> > > If this is possible, HTML CODE, PHP CODE, AND THE CSS CODE can be
> > > completely separate, increasing the clarity of all the source code.
> > >
> >         Yes.
> >         Take a look at Smarty. :-)
> >
> > http://smarty.php.net
> >
> > > My second question is:
> > > Is it more efficient to always code OOP PHP then just simple
> functions
> > here
> > > and there?
> >
> >         How big is your project?
> >         If you're talking about a personal visit counter, run away
> OOP.
> >         If you're talking about a really big project (And yes, CMS
> _is_ a
> > big
> > project), go ahead and use OOP.
> >
> >         OOP is better to mantain... :-)
> >
> >         HTH
> >
> > --
> > Davi Vidal
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > --
> > "Religion, ideology, resources, land,
> > spite, love or "just because"...
> > No matter how pathetic the reason,
> > it's enough to start a war. "
> > --------------------------------------------------------
> > Por favor não faça top-posting, coloque a sua resposta abaixo desta
> linha.
> > Please don't do top-posting, put your reply below the following line.
> > --------------------------------------------------------
> >
> >
>



--- End Message ---
--- Begin Message ---
kelvin,

here is the example:
catalog.php
<?php
$doc = new DOMDocument();
$xsl = new XSLTProcessor();
$doc->load('catalog.xsl');
$xsl->importStyleSheet($doc);
$doc->load('catalog.xml');
echo $xsl->transformToXML($doc);
?>

catalog.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>

catalog.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">

<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


in this example the xml data is imported from a file rather than built in
memory.  also, i would like to mention that most browsers, ie, firefox and
opera namely can render the xhtml themselves given the xml and xsl files
which is something you may want to consider.

-nathan


On 7/6/07, Kelvin Park <[EMAIL PROTECTED]> wrote:

Is it possible to have PHP code completely separate from the HTML page
that
needs to be completely dynamic? (That's how ASP.NET sort of works I
think).
If this is possible, HTML CODE, PHP CODE, AND THE CSS CODE can be
completely
separate, increasing the clarity of all the source code.

My second question is:
Is it more efficient to always code OOP PHP then just simple functions
here
and there?


--- End Message ---
--- Begin Message ---
fogot to copy the list on this as well; my bad :(

---------- Forwarded message ----------
From: Nathan Nobbe <[EMAIL PROTECTED]>
Date: Jul 7, 2007 3:00 PM
Subject: Re: [PHP] About PHP CMS
To: Kelvin Park <[EMAIL PROTECTED]>

On 7/7/07, Kelvin Park <[EMAIL PROTECTED]> wrote:
Looks like its quite a few steps to generate XHTML tags, from
PHP->XML->XSLT->XHTML, wouldn't it be more cumbersome to build a big website
(ex. commercial website)? Compare to just PHP->XHTML?

life is full of tradeoffs.  my understanding is there is a  tradeoff between
simplicity / complexity and performance / mantainability.  so if youre
trying to build something small that runs fast you can use the standard PHP
facility, ie
<?php
$myName = 'nathan';
?>
<html>
<head>
<title>
this is my page
</title>
<body>
my name is <?=$myName?>

there are other approaches as well; i personally prefer building the html as
a string, so the previous example would become
<?php
$htmlOut = '$myName = 'nathan';
<html>
<head>
<title>
this is my page
</title>
<body>
my name is ' . $myName;
echo $htmlOut;
?>
some people even build templating systems around these core PHP facilities.

but when building a large site templating systems facilitate the separation
between PHP and XHTML youre looking for.  i havent used Smarty, though ive
looked at it.
one of the big issues it presents is it is basically its own little
language, because logic can be embedded within a template.  so for instance,
if you want to build an HTML table and you have several rows worth of
content in an array, lets say, you could loop over the array within the
template producing the rows during said iteration.  so there is this issue
where a mistake could be made in the logic thats embedded in a Smarty
template, which begs the awesome question, how do you debug a Smarty
template?
so, truth be told, logic can be embedded in an xsl file as well.  really you
just need to create a set of conventions that dictate how much logic, if
any, will be allowed in template files.  that must be enforced for all
development on your site; the same could be done for a site built using
Smarty.  and also, i suppose there is an issue w/ broken logic in XSL
templates as well.  but the main reason i prefer XSL is because its a W3C
standard whereas Smarty is not.  also, XSL can be used w/ any language, not
just PHP so i feel i am more valuable knowomg i might be able to use XSL w/
other languages on other projects like java or .net or w/e.

i will send a sample when i get home, im at the office right now.

-nathan

On 7/7/07, Kelvin Park < [EMAIL PROTECTED]> wrote:

Looks like its quite a few steps to generate XHTML tags, from
PHP->XML->XSLT->XHTML, wouldn't it be more cumbersome to build a big website
(ex. commercial website)? Compare to just PHP->XHTML?

Yes, I would like to receive a sample of SimpleXML/DOM/XML.

Thanks!

On 7/7/07, Nathan Nobbe < [EMAIL PROTECTED]> wrote:
>
> > On 7/7/07, Kelvin Park <[EMAIL PROTECTED] > wrote:
> > Can XSLT be used to separate CSS/XHTML/PHP/AJAX completely?
> yes
>
> XSLT is used to map one set of XML to another set of XML, thats what the
> transform is all about.
> ive only been working with it for a while so im not that good yet, but
> what i do is build up XML data in
> PHP; that XML maps to points in an xsl file.  then i use the PHP XSLT
> functions <http://www.php.net/manual/en/ref.xslt.php> to render XHTML
>  by combining the XML data and the xsl file.  the XHTML is what gets
> sent to the browser via echo.
> you can use tools in PHP like SimpleXML and DOM to build up an XML
> document.  i can send you a sample
> if youd like.
>
> also, if you want to separate javascript from PHP and XHTML thats really
> a different issue.  in order to do that
> you need to link in javascript externally via the <script> tag instead
> of using inline scripts.  you may want to
> look at some frameworks like prototype <http://www.prototypejs.org/>,
> scriptaculous <http://script.aculo.us/> and jquery <http://jquery.com/>.
> but that is another universe altogether.
>
> -nathan
>
>
> On 7/7/07, Kelvin Park < [EMAIL PROTECTED]> wrote:
> >
> > Can XSLT be used to separate CSS/XHTML/PHP/AJAX completely?
> > Do you use XSLT with XHTML on a same file?
> > It seems like XSLT is derived from XML.
> >
> > On 7/7/07, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> > >
> > > to keep html separate from php you can also look at XSLT.
> > > ive heard good and bad things about smarty.
> > >
> > > -nathan
> > >
> > > On 7/6/07, Davi < [EMAIL PROTECTED] > wrote:
> > > >
> > > > Em Sexta 06 Julho 2007 21:24, Kelvin Park escreveu:
> > > > > Is it possible to have PHP code completely separate from the
> > > HTML page
> > > > that
> > > > > needs to be completely dynamic? (That's how ASP.NET sort of
> > > works I
> > > > think).
> > > > > If this is possible, HTML CODE, PHP CODE, AND THE CSS CODE can
> > > be
> > > > > completely separate, increasing the clarity of all the source
> > > code.
> > > > >
> > > >         Yes.
> > > >         Take a look at Smarty. :-)
> > > >
> > > > http://smarty.php.net
> > > >
> > > > > My second question is:
> > > > > Is it more efficient to always code OOP PHP then just simple
> > > functions
> > > > here
> > > > > and there?
> > > >
> > > >         How big is your project?
> > > >         If you're talking about a personal visit counter, run away
> > > OOP.
> > > >         If you're talking about a really big project (And yes, CMS
> > > _is_ a
> > > > big
> > > > project), go ahead and use OOP.
> > > >
> > > >         OOP is better to mantain... :-)
> > > >
> > > >         HTH
> > > >
> > > > --
> > > > Davi Vidal
> > > > [EMAIL PROTECTED]
> > > > [EMAIL PROTECTED]
> > > > --
> > > > "Religion, ideology, resources, land,
> > > > spite, love or "just because"...
> > > > No matter how pathetic the reason,
> > > > it's enough to start a war. "
> > > > --------------------------------------------------------
> > > > Por favor não faça top-posting, coloque a sua resposta abaixo
> > > desta linha.
> > > > Please don't do top-posting, put your reply below the following
> > > line.
> > > > --------------------------------------------------------
> > > >
> > > >
> > >
> >
> >
>


--- End Message ---
--- Begin Message ---
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.10.1/889 - Release Date: 7/6/2007 8:00 PM

--- End Message ---
--- Begin Message ---
I'm getting the following fatal error message:

*Fatal error*: Cannot instantiate non-existent class: domdocument in *
/home/hosting/infotechnow_com/htdocs/admin/inventory/catalog.php* on line *3
*
when running this code:

// Initialize new object for DOMDocument
$doc = new DOMDocument();

What's the problem?
**

--- End Message ---

Reply via email to