[pLog-general] Changing Templates Names.

Zaid B. Amireh zamireh at albawaba.com
Sun Oct 2 14:31:16 GMT 2005


Zaid B. Amireh wrote:

> Hi all,
>
> I need to rename all the templates that I have installed without 
> requiring the user to do a thing.
>
> in the plog_config table we have:
> templates = 
> 'a:11:{i:0;s:15:"blueish-English";i:1;s:12:"grey-English";i:2;s:16:"standard-English";i:3;s:13:"flower-Arabic";i:4;s:18:"pink_lilies-Arabic";i:5;s:11:"toni-Arabic";i:6;s:20:"pastel-blocks-Arabic";i:7;s:16:"girlsucks-Arabic";i:8;s:19:"desert_theme-Arabic";i:9;s:20:"fresh-bananas-Arabic";i:10;s:13:"ocadia-Arabic";}' 
>
>
> changing this won't be a problem, but I'm facing a problem with the 
> plog_blogs table, an example entry:
> settings = 
> 'O:12:"blogsettings":3:{s:6:"_objId";N;s:3:"log";N;s:6:"_props";a:11:{s:6:"locale";s:5:"en_UK";s:14:"show_posts_max";s:2:"15";s:8:"template";s:16:"standard-English";s:17:"show_more_enabled";s:1:"1";s:16:"recent_posts_max";s:2:"10";s:17:"xmlrpc_ping_hosts";a:1:{i:0;s:27:"http://rpc.weblogs.com/RPC2";}s:16:"htmlarea_enabled";s:1:"1";s:16:"comments_enabled";s:1:"1";s:16:"categories_order";i:0;s:14:"comments_order";s:1:"1";s:11:"time_offset";s:1:"0";}}' 
>
>
> as you can see, the chosen template is saved as a string and not an 
> integer so if I change the name of the template in the 
> plog_config.templates column then I need to change the name of the 
> template in the plog_blogs.config column too.
>
> Now, should I write a php script that uses the API provided by plog or 
> can I write something like the perl substitute command in mysql? a 
> better is highly appreciated.
>
> with regards
>
> Zaid Amireh
> _______________________________________________
> pLog-general mailing list
> pLog-general at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-general


Anyways, I solved this by writing a php script, here is the juicy part

#!/usr/bin/php
<?php

    define( 'PLOG_CLASS_PATH', '../' );

    //blogs DAO
    include_once(PLOG_CLASS_PATH.'class/dao/bloginfo.class.php');
    include_once(PLOG_CLASS_PATH.'class/dao/blogsettings.class.php');
    include_once(PLOG_CLASS_PATH.'class/dao/blogs.class.php');

    $allBlogs = new Blogs();

    $blogsIds = $allBlogs->getAllBlogIds();

    foreach( $blogsIds as $blogId ){

        $blogInfo = $allBlogs->getBlogInfo( $blogId );

        $oldTemplate = $blogInfo->getTemplate();

       //snip decision making about which template to use
       $newTemplate = 'New-Template';
       
        $blogInfo->setTemplate( $newTemplate );
       
        $allBlogs->updateBlog( $blogId, &$blogInfo );
   
    }   //end of foreach
?>


then I had to manually create a serialized plog_config.templates entry 
and then rename all the template folders to the new names.

just thought I would share :)

with regards

Zaid Amireh



More information about the pLog-general mailing list