Results 1 to 10 of 10
  1. #1
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25

    Lightbulb XSL approach to templating

    Hi!

    I see people complaining that custom made templates are difficult to merge with upcoming Pligg versions. Also currently code and look are still not enough separated. I worked out way to smoothly go over onto XSL templating. I spent just one day and made sample work of front page and story page only. I was able to merge completely new unrelated design into Pligg in fast and efficient way. Demo site is http://pligg.jes.ee . Check the source of page!

    I still work on it, so expect broken stuff and so on. But you are able to fetch most of code manually following links in source. Sample PHP code:
    Code:
    				$link=$db->select("*")
                                            ->from('digg_links')
                                            ->where('link_status="published"')
                                            ->orderby('link_date','desc')
                                            ->where('link_title_url="'.mysql_real_escape_string($_GET['title']).'"')
                                            ->limit(1)
                                            ->get();
    				foreach($link as $item) {
                                            $cd	= $root-> appendChild($doc->createElement('link'));
    
                                            $title	= $cd->	  appendChild($doc->createElement('title'));
                                            $title->appendChild($doc->createTextNode($item->link_title));
    	
                                            $title	= $cd->	  appendChild($doc->createElement('votes'));
                                            $title->appendChild($doc->createTextNode($item->link_votes));
    
                                            $title	= $cd->	  appendChild($doc->createElement('link'));
                                            $title->appendChild($doc->createTextNode($item->link_url));
    
                                            $title	= $cd->	  appendChild($doc->createElement('summary'));
                                            $title->appendChild($doc->createTextNode(strip_tags($item->link_summary)));
    
                                            $title	= $cd->	  appendChild($doc->createElement('content'));
                                            $title->appendChild($doc->createTextNode(strip_tags($item->link_content)));
    
                                            $title	= $cd->	  appendChild($doc->createElement('comments'));
                                            $title->appendChild($doc->createTextNode($item->link_comments));
    
                                            if(preg_match($pattern,$item->link_summary,$matches)){
                                                    $title	= $cd->	  appendChild($doc->createElement('image'));
                                                    $title->appendChild($doc->createTextNode(preg_replace($pattern,$img,$matches[0])));
                                            }
                                    }
    I propose to drop old smary way and go over to this. Modifications to go over are simple and as benefit users get full control over their layout independently from Pligg development and patches. Also this works faster and makes less load to server.

    What do you say?

  2. #2
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25
    Forgot to mention - this dramatically reduces bandwidth used because we move only data. XSL files can be forced to stay 10 years in browser cache. This again mean extreme speed on client side when just sinlge small data needs to be downloaded.

  3. #3
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25
    more code samples:
    Code:
             	$doc = new DOMDocument('1.0','utf-8');
    		$doc->formatOutput = true;
    		if(!@$_GET['title']){
    			$doc->appendChild(new DOMProcessingInstruction('xml-stylesheet' ,'type="text/xsl" href="titlepage.xsl"'));
    		} else {
                            $doc->appendChild(new DOMProcessingInstruction('xml-stylesheet' ,'type="text/xsl" href="story.xsl"'));
    		}

  4. #4
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25
    If you want to test speed difference compare it to http://www.digg.ee which is in same computer.

  5. #5
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25

    improved!

    Now falls back to "old stupid browser compatibility mode" when sees user-agent Konqueror, links, lynx or HTML validator. Then you see different source. Works well without it on IE6+, Firefox, Opera, Chrome, Safari. I think this is good enough.

  6. #6
    New Pligger bendi's Avatar
    Joined
    Nov 2008
    Posts
    9
    tanuonu - you know what's the reason to use templates in the first place? It's the designers - to separete their work from programmers, the two teams can work independently. What pligg team is doing is fixing a loot of bad decissions done in the past and this has got to break compatiblity.

    Your idea is perfect for programmers but breaks the whole idea from designer point of view, so I don't think this will get any attention.

    To get templates better and cleaner, you'd have to get rid of nasty {php} tags in the first place and do the real job of moving all of it into model/controller.

    You can check out my code (/trunk/templates/yget2 - fligg - Trac) and changes to yget template (renamed yget2 for my own purposes) to see how tough the it is. Oh and one more thing - my code changes break WHOLE backward compatibility with pligg

  7. #7
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25
    I am succeeded separating them without breaking compatibility too much.

  8. #8
    New Pligger tonuonu's Avatar
    Joined
    Jul 2007
    Posts
    25
    I went live with this on digg.ee. I call Pligg develiopers to accept my code and improve it together.

  9. #9
    Pligg Founder Yankidank's Avatar
    Joined
    Dec 2005
    Location
    San Francisco, CA
    Posts
    5,063
    Site
    http://pligg.com/demo/
    I appreciate the effort, but I don't think that XSL is the proper method for templating sites. I'm sure that some people might use that method to create their site, but it's just not the standard way to design websites that web designers are used to. The current .tpl approach seems to be pretty friendly to users who are familiar with HTML/CSS design and I don't think that XSL is going to be as intuitive to the web design community. I think that bendi was right on with his post.
    The Facebook Module for Pligg CMS!
    Register, Login, and Submit Stories with Facebook. An absolute MUST HAVE for all Pligg sites!

  10. #10
    Donor Techkr's Avatar
    Joined
    Jun 2007
    Posts
    289
    I want to see example but your site down
    Code:
    ERROR
    The requested URL could not be retrieved
    
    While trying to retrieve the URL: http://pligg.jes.ee/
    
    The following error was encountered:
    
        * Connection to Failed 
    
    The system returned:
    
        (146) Connection refused
    
    The remote host or network may be down. Please try the request again.
    
    Your cache administrator is abuse@estpak.ee.
    Generated Thu, 16 Apr 2009 01:36:25 GMT by proxy.jes.ee (squid)

Similar Threads

  1. Understand Pligg CSS and Templating Approach
    By Adaman in forum Questions & Comments
    Replies: 11
    Last Post: 04-30-2008, 11:15 AM
  2. Approach in supporting languages
    By Roland in forum Questions & Comments
    Replies: 0
    Last Post: 02-11-2008, 04:15 PM
  3. Templating
    By Geoserv in forum Questions & Comments
    Replies: 2
    Last Post: 01-18-2008, 06:51 PM
  4. Templating was painless Thanks!
    By newuser in forum Questions & Comments
    Replies: 8
    Last Post: 10-18-2006, 01:28 PM
  5. Pligg's Templating
    By nanome in forum Questions & Comments
    Replies: 11
    Last Post: 09-10-2006, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting