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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.