We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom date field as entry date on weblog posting

Development and Programming

keehun's avatar
keehun
8 posts
16 years ago
keehun's avatar keehun

Moved by Moderator to Extensions: Technical Assistance

Hello,

I currently have a calendar based off a weblog (That’s working very well) and the events automatically posted to a forum thread for people to talk about, etc. However, in order for it to show up on the right day, I need to modify the entry date in the tab, however, as other users will be posting with it, it gets inconvenient and there’s three calendars, etc (confusing) so I created all custom fields with very simple labels, such as “What” “Where” “When” “Why” (why being description of the event) and I would love it if the “When” was used instead of post entry calendar in the tab.. I already use a little extension posted in another thread I don’t have the link to anymore, but I think it hooks to the blog posting which is used to post it to the forum. Is it possible that I edit the entry date here with the custom field?

Code for the hook (I do not take credit for this code. It was written by someone else in another thread):

<?php

if ( ! defined('EXT'))
{
    exit('Invalid file request');
}


class Forum_fill 
{
    var $settings        = array();
    
    var $name            = 'Automated Forum Filler';
    var $version        = '1.0.0';
    var $description    = 'Creates forum data from weblog post';
    var $settings_exist    = 'n';
    var $docs_url        = 'http://media-cow.com/';
    
    // -------------------------------
    //   Constructor - Extensions use this for settings
    // -------------------------------
    
    function Forum_fill($settings='')
    {
        $this->settings = $settings;
    }
    // END


    function forum_data()
        {
        global $IN;

            if ($IN->GBL('weblog_id', 'POST') == 2)
            {
                $_POST["forum_title"] = $IN->GBL('title', 'POST');
                $_POST["forum_id"] = 12;
                $_POST["forum_body"] = preg_replace("/\[\[.*?\]\]/s", "", $IN->GBL('field_id_2', 'POST'));       
            }
            elseif ($IN->GBL('weblog_id', 'POST') == 3)
            {
                $_POST["forum_title"] = $IN->GBL('title', 'POST');
                $_POST["forum_id"] = 13;
                $_POST["forum_body"] = "Where: [b]".$IN->GBL('field_id_5', 'POST') . "[/b]
When: ".$IN->GBL('field_id_6', 'POST')."

".$IN->GBL('field_id_7', 'POST');
            }
                    return;
        }
    
    
    // --------------------------------
    //  Activate Extension
    // --------------------------------
    
    function activate_extension()
    {
        global $DB, $PREFS;
        $DB->query($DB->insert_string('exp_extensions',
                                      array('extension_id'    => '',
                                            'class'            => "Forum_fill",
                                            'method'        => "forum_data",
                                            'hook'            => "submit_new_entry_start",
                                            'settings'        => "",
                                            'priority'        => 10,
                                            'version'        => $this->version,
                                            'enabled'        => "y"
                                            )
                                     )
                   );

    }
    // END
    
    
    // --------------------------------
    //  Update Extension
    // --------------------------------  
    
    function update_extension($current='')
    {
        if ($current == '' OR $current == $this->version)
        {
            return FALSE;
        }
        
        if ($current > '1.0.0')
        {
            // Update to next version 1.0.1
        }
        
        $DB->query("UPDATE exp_extensions 
                    SET version = '".$DB->escape_str($this->version)."' 
                    WHERE class = 'Forum_fill'");
    }
    // END
    function settings()
    {
    $settings = array();
    return $settings;
    }
    // END
 
     
    function disable_extension()
    {
    global $DB;
    $sql = "DELETE FROM exp_extensions WHERE class = 'Forum_fill'";      
    $DB->query($sql);
    }    

 
}
// END Class

?>

I’m guessing its a line or two of addition but I simply have no clue..

Thanks! Keehun

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Hi, Keehun.

This post is outside of normal technical support. I’m going to move it into the Extensions forum for additional help.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.