SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MVC is the "buzzword", but does he really worth it ?
    Back the original question - there are "concerns" about MVC(2) and whether it's really a good model for web applications. There may be something fundamentally wrong or it may be that the Java crowd, who went mad for Struts, are realizing it's limitations. In other words it may be the standard implementation is a problem or there could be a fundamental problem - I don't know.

    Bottom line is, if you're unsure whether it's for you, it can be a large waste of time to go down this road, especially if it means building your own MVC framework. You might consider one of the existing MVC frameworks written in PHP but get advice (like here) first before choosing one.

    Using classes like those available from PEAR to help avoid re-inventing wheels, while sticking to switches and if/else statements for controlling your application will mean your projects definately get finished, even if they feel "hacky".

  2. #27
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    Arizona
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One other problem that I have found is that everyone has their own interpretation the Model-View-Controller concept. Since the concept is so general, everyone has to come up with their own specifics. This gives rise to the development of many different implementations. The only "right" way to implement MVC probably has something to do with the question: "Does MVC apply to and solve your specific problem?"

    Azmo: I am interested in your configuration-driven architecture. Do you have any examples posted?

    JT

  3. #28
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Elsewhere
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seratonin
    I like what Terence Kearns is doing over at:

    http://xao-php.sourceforge.net
    I've taken a look at XAO in the past, and I quickly lost interest because it relies on XML so heavily (most PHP applications that do this get it wrong). But after taking a closer look, I must say I'm really impressed! It looks like Terence's ideas behind his framework are similar to mine. I just don't use XML and XSLT, because XML is generally slower than native PHP (or used to be), and XSLT is used and known too little right now. He makes a good case about XML and XSLT, though.

    Quote Originally Posted by seratonin
    Azmo: I am interested in your configuration-driven architecture. Do you have any examples posted?
    I posted a description and an example of my architecture in this topic. The first four posts are about a different subject. If you (or anyone else) have a comment or question about my architecture, please put it in that thread, so we can keep this one on topic.

  4. #29
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or used to be
    Yes, I noticed this as well, though this was with in relation to the Sablotron extension.

    Using the DOM, you have very little overhead. As to the lack of XSL-T knowledge (my own is 'enough to get by') I put down to the fact that a lot of people simply shy away from it, preferring to use a third party tool instead to transform the document.

    Shame really, as XSL-T and X-PATH are both very powerful techs.

  5. #30
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...example of my architecture ...
    Wow

    Like, I'm currently reading through #5 just now, and I was impressed on how you handle your 'devices', but more so on how you do a template

    Great stuff. Going to read more

  6. #31
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by HarryF
    Using classes like those available from PEAR to help avoid re-inventing wheels, while sticking to switches and if/else statements for controlling your application will mean your projects definately get finished, even if they feel "hacky".
    Absolutely! I've been messing with frameworks for a while now. Never completely satisfied (not saying any are bad or anything). Just never fit me. A few days ago I started coding a new site. I'm using PEAR DB_DataObject and QuickForm/QuickForm_Controller and let me tell you... Wow! Those two tools alone are really shining for me. I have a simple page as the controller file (add.php for example) and it calls the form objects, and the data objects. My controller files look very clean. Just instantiating a few objects. And the rest is in the classes. And still all very clean. And so easy to understand (no framework to figure out!). I'm going to stick with this method for a while until I start to see some patterns in the way I'm developing, and maybe then build a VERY lightweight 'framework' to help with duplication. As far as MVC...

    I think MVC has worked for me in ways. If you have a basic controller file and call a module. A module would be a combination of an action (another modle specific controller), a model and a view. The module is very basic. Handling manipulation of a single (and/or related models). I execute the module, which calls the action, the action returns the view type and the module calls the view controller. The view controller returns a string of the output (from a template, or template engine). Now I have the output of the module in my main controller (the request file). From there, I can do a composite view pattern. Calling any other modules, and fitting them into a master view (or even more sub-views). It looks kind of like this:

    PHP Code:
    $journalModule =& new Module('journal');
    // i like the module to not know where the request vars are coming from. It's an associative array. Could be straight from $_GET or anything else.
    $journal_output =& $journalModule->execute('showMainPage'$request_vars);

    $loginFormModule =& new Module('LoginForm');
    $login_form_output =& $loginFormModule->execute('showForm'$request_vars);

    $pageBodyView =& new PageBodyView($journal_output);
    $sideMenuView =& new SideMenuView($login_form_output);
    $mainView =& new MainPageView($pageBodyView->getOutput());
    $mainView->set('rightColumnContent'$login_form_output);

    echo 
    $mainView->getOutput(); 
    That's MVC, and it's very easy to understand. The MVC is within the Modules. There is lots of separation here. I didn't feel comforable at all with MVC, until I learned about the composite view pattern. Does that make any sense? When I tried making a basic MVC application, I was always like, well now what? But capturing the output of a single MVC 'block' means you can do whatever you want with it.

    Matt

  7. #32
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This looks interesting

    Where I basically build an "object" model of document which aggregates content from different sources.
    Can we all have a look ? Please.

  8. #33
    SitePoint Enthusiast acostin's Avatar
    Join Date
    Mar 2002
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    We also use MVC extensively for complex applications

    And once you enter the ASP (application service providers) world, separating the application logic from the presentation layer is a must for a serious business - you will be able to launch hundreds of sites that share the "same" application logic, and the maintenance benefits are enormous

    Quote Originally Posted by seratonin
    I like to use the Content Aggregation Pattern for composite views. JT
    Our open Krysalis platform has this - and the best implementation is in the Komplete product - http://klite.interakt.ro/ where all major sections of the screen are aggregated from various pipes that are described in the controller.

    We can now change pretty easily how the application behave from a single point, and even if neither the platform, nor the CMS are perfect, we are working hard to make the whole being compiled as pure PHP code for speed.

    The idea with MVC is to be able to represent the application logic in a way other programmers can understand easier - that is why people build frameworks, taglibs, classes - to make sure they have a generally accepted definition of an application that can be understood by others when they takeover your application.

    Alexandru

  9. #34
    SitePoint Zealot
    Join Date
    Dec 2003
    Location
    with my kids
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    Such as what I have at the moment for example

    PHP Code:
    class ViewGenerator {
            var 
    $header_;
            var 
    $footer_;
            var 
    $template;
            
            function 
    ViewGenerator$filename ) {
                if( !
    file_exists$filename ) ) {
                    
    ErrorReport::Invoke200 );
                    die();
                }
                
    $fp = @fopen$filename'r' );
                
    $template = @fread$fp, @filesize$filename ) );
                @
    fclose$fp );
                
                
    $this -> template = &$template;
                
    $this -> Header();
                
    $this -> Footer();
            }
            
            function 
    Header() { 
                
    $fp = @fopen'templates/header.html''r' );
                
    $header = @fread$fp, @filesize'templates/header.html' ) );
                @
    fclose$fp );
                
                
    $this -> header_ = &$header;
            }
            
            function 
    Footer() {
                
    $fp = @fopen'templates/footer.html''r' );
                
    $header = @fread$fp, @filesize'templates/footer.html' ) );
                @
    fclose$fp );
                
                
    $this -> footer_ = &$footer;
            }
            
            function 
    Replace$tag$string ) {
                
    $this -> template ereg_replace$tag$string$this -> template );
            }
            
            function 
    Finalise$header ''$footer '' ) {
                echo( empty( 
    $header )? $this -> header_:$header );
                echo( 
    $this -> template );
                echo( empty( 
    $footer )? $this -> footer_:$footer );
                die();
            }
        } 


    Works fine so far ;)
    oh for the love of God, you're kidding right?
    PHP Code:
    <?php
    include 'header.php';
    include 
    'template.php';
    include 
    'footer.php';
    ?>

  10. #35
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by josheli
    oh for the love of God, you're kidding right?
    PHP Code:
    <?php
    include 'header.php';
    include 
    'template.php';
    include 
    'footer.php';
    ?>
    Interesting. Assuming that the ViewGenerator API is used for something we haven't seen yet, here's an alternative that keeps the API constant:

    PHP Code:
    class ViewGenerator {
            var 
    $header_;
            var 
    $footer_;
            var 
    $template;
            
            function 
    ViewGenerator$filename ) {
                if( !
    file_exists$filename ) ) {
                    
    ErrorReport::Invoke200 );
                    die();
                }
                
    $this -> template =@file_get_contents($filename);
                
    $this -> header_ = @file_get_contents('templates/header.html');
                
    $this -> footer_ = @file_get_contents('templates/footer.html');
            }
            
            function 
    Replace$tag$string ) {
                
    $this -> template ereg_replace$tag$string$this -> template );
            }
            
            function 
    Finalise$header ''$footer '' ) {
                echo( empty( 
    $header )? $this -> header_:$header );
                echo( 
    $this -> template );
                echo( empty( 
    $footer )? $this -> footer_:$footer );
                die();
            }
        } 

    Simpler yet, and more efficient since the header.html and footer.html aren't read unless it's necessary:

    PHP Code:
    class ViewGenerator {
            var 
    $template;
            
            function 
    ViewGenerator$filename ) {
                if( !
    file_exists$filename ) ) {
                    
    ErrorReport::Invoke200 );
                    die();
                }
                
    $this -> template =@file_get_contents($filename);
            }
            
            function 
    Replace$tag$string ) {
                
    $this -> template ereg_replace$tag$string$this -> template );
            }
            
            function 
    Finalise$header ''$footer '' ) {
                echo empty( 
    $header )
                    ? @
    file_get_contents('templates/header.html')
                    : 
    $header;
                echo( 
    $this -> template );
                echo empty( 
    $footer )
                    ? @
    file_get_contents('templates/footer.html')
                    : 
    $header;
                die();
            }
        } 
    (Haven't tested it, there could be bugs.)
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  11. #36
    SitePoint Zealot
    Join Date
    Dec 2003
    Location
    with my kids
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you guys crack me up.

  12. #37
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by josheli
    you guys crack me up.
    Yes, we're all one harmonious family, devoted to making each other happy.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  13. #38
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Elsewhere
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the whole 'header - main - footer' abstraction is an oversimplification of webpages. It also focusses on a visual representation of the Document, which I consider a bad thing.

    I put one or more Blocks of content into a Document. Where they fit into the Document isn't important.

  14. #39
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Josheli -

    PHP Code:
    <?php 
    include 'header.php'
    include 
    'template.php'
    include 
    'footer.php'
    ?>
    Are you suggesting I use your idea ? If I had to do that, then please tell me how I'd actually manage to replace some tags with my content ?

    You see, I do not have PHP within my HTML - What a disgusting thought

    Dagfinn - Thanks mate See the improvement right away, so will be looking at it later.

    Azmo - Saw your arch. from another link the other day there, and still looking for more time to look at your ideas

  15. #40
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You see, I do not have PHP within my HTML - What a disgusting thought
    All I can say is: what a disgusting thought to think that it is a disgusting thought to have PHP within your html

    You see, I do not have Smarty tags within my HTML - What a disgusting thought



  16. #41
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Smarty ? No... God No....

    Each to their own though, I can very easilly now change the ViewGenerator without too much trouble to accept XML - just now the templates are all xHTML

    Simpler yet, and more efficient since the header.html and footer.html aren't read unless it's necessary
    After some more refactoring, the ViewGenerator requires a seperate Body, Header and Footer, depended on an given Action, via a configuration file.

    A whole lot more flexible now, and more effiecent

    Here is the complete class now, just for the sake of showing off

    PHP Code:
    # version 0.04e 29.02.04
        
        
    class DisplayDriver {
            var 
    $body_;
            var 
    $header_;
            var 
    $footer_;
            var 
    $content;
            var 
    $template;
            
            function 
    DisplayDriver$ar ) {
                
    # access required templates
                
    $this -> Body$ar['templates']['body'] );
                
    $this -> Header$ar['templates']['header'] );
                
    $this -> Footer$ar['templates']['footer'] );
                
                
    # check file required exists
                
    if( !file_exists$ar['templates']['template'] ) ) {
                    
    ErrorReport::Invoke200 );
                    die();
                }
                
                
    $fp = @fopen$ar['templates']['template'], 'r' );
                
    $content = @fread$fp, @filesize$ar['templates']['template'] ) );
                @
    fclose$fp );
                
    #
                
    $this -> content $content;
                
    $this -> template $this -> header_ $this -> body_ $this -> footer_;
            }
            
            function 
    Body$template ) {
                
    $fp = @fopen$template'r' );
                
    $this -> body_ = @fread$fp, @filesize$template ) );
                @
    fclose$fp );
            }
            
            function 
    Header$template ) {
                
    $fp = @fopen$template'r' );
                
    $this -> header_ = @fread$fp, @filesize$template ) );
                @
    fclose$fp );
            }
            
            function 
    Footer$template ) {
                
    $fp = @fopen$template'r' );
                
    $this -> footer_ = @fread$fp, @filesize$template ) );
                @
    fclose$fp );
            }
            
            function 
    Paste$tag$string ) {
                
    # replace a tag with data on a non - page content template structure
                
    $this -> template ereg_replace$tag$string$this -> template );
            }
            
            function 
    PasteSpecial$tag$string ) {
                
    # replace a tag with data on a given pages content structure
                
    $this -> content ereg_replace$tag$string$this -> content );
            }
            
            function 
    Finalise() {
                
    # finalise web page completely, and output to web browser
                
    $this -> Paste'<body />'$this -> content );
                
                echo( 
    $this -> template );
                die();
            }
        } 
    And some - older - templates to demonstrate the point.

    Body.html

    PHP Code:
        <table border="0" width="896" align="center" cellspacing="0" cellpadding="0">
            <
    tbody>
            <
    tr>
            <
    td width="100%" align="center" height="24" valign="center"><heading /></td></tr>
            <
    tr>
            <
    td width="100%" align="center" height="16" valign="center">
                [ <
    a href="index.php?Act=LogOut">Log Out</a> . 
                <
    a href="index.php?Act=Admin">Admin</a> . 
                <
    a href="index.php?Act=ManageUsers">Manage Users</a> . 
                <
    a href="index.php?Act=ManageNews">Manage News</a> ]
            </
    td></tr>
            <
    tr>
            <
    td width="100%" height="16">&nbsp;</td></tr>
            <
    tr>
            <
    td width="100%" align="center" valign="top">
                <
    body />
            </
    td></tr>
            <
    tr>
            <
    td width="100%" height="16">&nbsp;</td></tr>
            <
    tr>
            <
    td width="100%" align="center" height="24" valign="center">Application &copy;2004 Rights Reserved.</td></tr
    Header.html

    PHP Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title />
        <link rel="stylesheet" type="text/css" media="screen" href="templates/css/stylesheet.css" />
    </head><body>
        <table class="null" border="0" width="100%" align="center" height="100%" valign="top" cellspacing="0" cellpadding="0">
        <tbody>
        <tr>
        <td width="100%" align="center" height="100%" valign="top">
        <br />
    Footer.html

    PHP Code:
    </td></tr>
        </
    tbody></table>
    </
    body></html
    And lastly the Content

    PHP Code:
    <tr id="row">
    <
    td width="20%" align="right" height="16" valign="center"><date />&nbsp;</td>
    <
    td width="30%" align="left" valign="center">&nbsp;<fullname /></td>
    <
    td width="20%" align="left" valign="center">&nbsp;<role /></td>
    <
    td width="30%" align="left" valign="center">&nbsp;<contact /></td></tr
    Enjoy

  17. #42
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...aggregated from various pipes that are described in the controller.
    I'm thinking this exact same thing myself, although not from the Controller, but via a configuration file.

    Some time off though

  18. #43
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the complete class now, just for the sake of showing off
    Since you asked for feedback, the Header, Body & Footer methods restate the same basic function (as do paste & paste special).

    Can you write the class without mentioning Header, Body or Footer?

    This might make some interesting reading: http://www.refactoring.com/catalog/index.html.

  19. #44
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fair enough, I could have the Header, Footer and Body all rolled into the one class method McGruff, but there is nothing wrong with having one of each to explain it's purpose IMO.

    About the Paste* methods though, I needed to seperate these, since there is two differing templates used in my pages. I could have 'Content' within a specific - to an action - 'Body' but that introduces duplication.

    I could just have the one method - Paste - and pass in either

    PHP Code:
    $this -> template 
    or
    PHP Code:
    $this -> content 
    But I don't see the point of having to pass around a classes property in that manner.

    About your link, do you have any suggestions on what to follow up ?

  20. #45
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't use the header/footer thing. If it doesn't render correctly in a common html editor (Dreamweaver) I don't use it. I will never break up my templates into invalid html documents.

    That's why I make a master view document, and then plug-in blocks of components. My main view is a pre-made sandwich, and is all valid html. No breaks of html. It contains the header and footer and tags. All of the tags are also complete html. Can you show me how you'd handle that with your ViewGenerator?

    matt

  21. #46
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    Fair enough, I could have the Header, Footer and Body all rolled into the one class method McGruff, but there is nothing wrong with having one of each to explain it's purpose IMO.
    Anything repeated is best resolved into a single source.

  22. #47
    SitePoint Zealot sleepeasy's Avatar
    Join Date
    Sep 2003
    Location
    Bristol, UK
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mwmitchell
    That's why I make a master view document, and then plug-in blocks of components. My main view is a pre-made sandwich, and is all valid html. No breaks of html. It contains the header and footer and tags. All of the tags are also complete html. Can you show me how you'd handle that with your ViewGenerator?
    This is similar to how I currently handle displaying content, with the exeption that my Master Document is pure XML (which needs to be transformed) as opposed to (X)HTML which can be displayed straight away.

    Leaving out a few details, it works as follows:
    Applications/ actions that produce XML add their XML to the Master Document. The "controller" for the application/action sets which stylesheet to use for the applications XML, and can also set options on the transformation for the Master Template (these options are taken from configuration files)

    base template (includes all the stylesheets)
    Code:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" indent="no" omit-xml-declaration="yes" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd"/>
      <xsl:include href="mastertemplate.xml"/>
      <xsl:include href="login.xml"/>
      <xsl:include href="menu.xml"/>
    </xsl:stylesheet>
    master template:
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    	<xsl:template match="/Pepper">
        <html xmlns="http://www.w3.org/1999/xhtml">
    		<head>
    			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
    			<title><xsl:value-of select="site-name"/> - <xsl:value-of select="capsule[@type='content'][1]/title"/></title>
    			<link rel="stylesheet" href="{theme-path}setup.css"/>
    		</head>
    		<body>
    			<div id="wrap">
    				<a id="skiplink" href="#content-start" title="Skip to the main content" accesskey="2">skip</a>
    				<div id="header"><xsl:apply-templates select="capsule[@id='MenuMaster']/menu[@id='LoginLogout']"/><h1><a href="{site-url}" title="{site-name} Home"><xsl:value-of select="site-name"/></a> <xsl:value-of select="capsule[@type='content'][1]/title"/></h1></div>
    				<div id="mooseriot">
    					<div id="filler"><xsl:apply-templates select="capsule[@id='MenuMaster']/menu[@id='Main']"/></div>
    				</div>
    				<div id="coaster">
    					<xsl:if test="capsule[@type='sidebar'] or capsule[@type='content']/menu">
    					<div id="sidebarleft">
    						<xsl:apply-templates select="capsule[@type='content']/menu"/>
    						<xsl:for-each select="//capsule[@type='sidebar']">
    							<div class="block">
    								<xsl:apply-templates select="."/>
    							</div>
    						</xsl:for-each>
    					</div>
    					</xsl:if>
    					<xsl:apply-templates select="capsule[@type='content']" />	
    				</div>
    			</div>
    		</body>
    		</html>
    	</xsl:template>
    </xsl:stylesheet>
    Each part of the Master Document is wrapped in a "capsule" element. Any template options are set as attributes on this element, such as the "type" attribute. The Master Template can the use these options, for example, to control what goes where.

    The method I use may seem weird to some people, I don't know. I'm very pleased with how it works, although a few refinements are needed before I'm perfectly happy with it.
    Always open to question or ridicule

  23. #48
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Weird ? Not at all, looking at your Master Template, kind of explains it's self on what it's doing, from my understanding of an XSL Stylesheet - can you post the 'menu.xml' file as well though ?

    Would appreciate that

    Matt - Having one document compared against seperate Header/Footer has it's advantages - but also disadvantages. Thinking carefully about this, I decided to have the Header and Footer seperate, for me had more benifits.

    But it's not to everyone's tastes. As to actually displaying a web page as you've suggested would require a different class I suppose, but in saying that, wouldn't be too difficult to do

    I see that McGruff's still not happy about me having a seperate Header et al huh ?

    Maybe one day I'll introduce a SWITCH in there

  24. #49
    SitePoint Zealot sleepeasy's Avatar
    Join Date
    Sep 2003
    Location
    Bristol, UK
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    Weird ? Not at all, looking at your Master Template, kind of explains it's self on what it's doing, from my understanding of an XSL Stylesheet - can you post the 'menu.xml' file as well though
    Sure:

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> 
    	<xsl:strip-space elements="*"/>
    
    	<!-- For TOC menu's etc -->
    	<xsl:template match="//capsule[@type='content']/menu">
    		<div class="block">
    			<ul id="menu">
    				<xsl:for-each select="menu-item">
    					<xsl:variable name="id" select="@id"/>
    					<li><xsl:apply-templates select="." /></li>
    					<li><xsl:apply-templates select="//menu[@id=$id]" /></li>
    				</xsl:for-each>
    			</ul>
    		</div>
    	</xsl:template>
    
    	<!-- Produces inline menu's -->
    	<xsl:template match="menu">
    		<ul id="{@id}">
    		<xsl:for-each select="menu-item">
    			<li class="inline"><xsl:apply-templates select="."/></li>
    		</xsl:for-each>
    		</ul>
    	</xsl:template>
    
    	<xsl:template match="menu-item">
    		<xsl:choose>
    			<xsl:when test="@disabled = 'true'">
    				<!-- Naughty use of <abbr> -->
    				<abbr title="Link temporarily disabled."><xsl:value-of select="name"/></abbr>
    			</xsl:when>
    			<xsl:when test="@id = //capsule/@id">
    				<a class="current" href="{uri}" title="{description}"><xsl:value-of select="name" /></a>
    			</xsl:when>
    			<xsl:otherwise>
    				<a href="{uri}" title="{description}"><xsl:value-of select="name" /></a>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>
    Always open to question or ridicule


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •