SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic content in cms pages problem ??

    Hello forums!!
    I would like to know how to insert some dynamic contents in cms pages.
    Suppose we have a contact us page as:
    Contact US:
    bla bla content 1
    bla bla content 2
    but i would like to insert some dynamic contents like contact us form etc in above page as:
    Contact US:
    bla bla content 1
    <!-- contact us form goes here.. -->
    bla bla content 2
    <!-- another dynamic content goes here.. -->
    How to accomplish such in content management system.
    Any help,ideas, suggestions etc are appreciated.
    Thanks

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This varies highly on how it's coded, if all the content is output as one you'll need to do some customizing, depending on how complex the app is. if they're split up you could echo the first part or save the string as a variable, then output the form, content area 2, etc.

    You won't get a specific answer unless you post the code.
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I saw that some of the cms make a use of eval for executing the contents,
    I dont think this approach is appropriate as eval() is considered to be an evil.
    Any other alternatives ??

  4. #4
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very hard to suggest anything without seeing the source, really.
    Cross browser css bugs

    Dan Schulz you will be missed

  5. #5
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    generally cms database has a table called pages as:
    id | page_title | page_body | is_active |
    1 | Home | home blabla| 1|
    2 | About Us| contents... | 1|

    which is simply fetched from the pages table and displayed in the frontend.
    This is what i am accomplishing.
    I think the case is clearer now, right?

  6. #6
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Knock Knock !!

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Giving this thread a free bump because I'm interested to hear people's opinions on this topic as well.

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    5 Thread(s)
    Quote Originally Posted by PHPycho
    I saw that some of the cms make a use of eval for executing the contents,
    I dont think this approach is appropriate as eval() is considered to be an evil.
    Any other alternatives ??
    Use classes rather then HTML templates to represent each view.

    PHP Code:
    <?php
    class BlogView extends AppView {

        public function 
    javascript(Viewable $pView=null) {
        
            
    parent::javascript($pView);
            
    $pagination $this->getVar('pagination'); ?>
            
            <script type="text/javascript">
            hash.push(function() {
            <?php echo $pagination->dropDownJavascript('pagination-drop-down'); ?>
            });
            </script>
        
        <?php }

        public function 
    render() {
            
            
    $path $this->getVar('path');
            
    $pagination $this->getVar('pagination');
            
    $entries $this->getVar('blogEntries');
            
            
    $page $pagination->getPage();
            echo 
    '<p>page ',$page,' of ',$pagination->pages(),'</p>';
            
            if(
    $this->getVar('client')->isAdmin()===true) {
                echo 
    '<a href="'.Pathway::entry.'/create-blog-entry">new blog entry</a>',"\n";
            }
            
            if(
    $entries) {
            
                foreach(
    $entries as $entry) {
            
                    echo 
    '<h2><a href="',Pathway::entry,'/blog-entry/',$entry->id,'/">',$entry->title,'</a></h2>';
                    echo 
    '<p>',date('M j, Y, g:ia',strtotime($entry->created)),'</p>';
                    echo 
    '<p>',$entry->user->name,'</p>';
                    echo 
    '<p>',$entry->comment_count,'</p>';
            
                }
            }
            
            
    $url $path->makeUrl(array('page'=>'{page}'));
            
            echo 
    $pagination->makeMenu($url);
            echo 
    $pagination->makeDropDown($url,'pagination-drop-down');
        
        }

    }

    ?>
    Anything that implements the below interface can essentially be viewed in my system:

    PHP Code:
    <?php
    interface Viewable {

        public function 
    setVar($pName,$pValue);
        public function 
    getVar($pName);
        public function 
    hasVar($pName);
        public function 
    meta(Viewable $pView=null);
        public function 
    css(Viewable $pView=null);
        public function 
    javascript(Viewable $pView=null);
        public function 
    render();

    }
    ?>
    This is my solution to avoiding eval which I hate.


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
  •