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

Need PHP help to add logic to Robin Sowell’s forum_fill extension

Development and Programming

craiguffman's avatar
craiguffman
100 posts
16 years ago
craiguffman's avatar craiguffman

I am using Robin Sewell’s forum_fill extension. It works beautifully for me (thank you, Robin), but I need to modify the logic for creating the text that gets copied from my weblog entry into the content of my forum topic post. I already have this logic working in an EE template that displays the weblog entry on a single page; I then use the same logic that EllisLabs uses for their own blog, with a “Discuss This Post” link to my forums, where I want discussion to be driven. I need a line of the logic in my template to be executed in the forum_fill extension so that I end up with two additional data elements (“channel” and “author”) being put into the forum topic before the main body content (“description”). I then need a blank line to follow the body before adding the “Read the original” which is the backlink to my weblog entry. Unfortunately, because I don’t know PHP, I don’t know how to translate my template logic into PHP.

As I understand this, Robin builds a “post” currently that consists of forum_title, forum_id, and forum_body, and then a backlink ($linkage). But I need a bit more from my weblog: I need it to become a post that consists of forum_title, forum_id, channel, author, a blank line, forum_body, a blank line, and $linkage.

  1. Can someone tell me how to do that?
  2. Also, can someone tell me how to limit the execution to those weblog entries that are open, and, indeed, trigger it when I set a weblog entry to open, so that it matters not at all whether it is thru the publish or edit tabs of the CP?

Here’s the template logic I need to put into Robin’s PHP code:

 {related_entries id="item_source"}{if no_related_entries} {/if} 
Channel:<i> {title} </i>           {/related_entries}
{if item_author}  Author: {item_author} {/if}

Here’s what I believe to be the relevant part of Robin’s extension, as already modifed for my site:

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;
    $linkage = "\nView the <a >original post</a>";
if ($IN->GBL('weblog_id', 'POST') == 4)
        {
            $_POST["forum_title"] = $IN->GBL('title', 'POST');
            $_POST["forum_id"] = 8;
            $_POST["forum_body"] = $IN->GBL('field_id_6', 'POST').$linkage;
  
        }
        elseif ($IN->GBL('weblog_id', 'POST') == 6)
        {
            $_POST["forum_title"] = $IN->GBL('title', 'POST');
            $_POST["forum_id"] = 3;
            $_POST["forum_body"] = $IN->GBL('field_id_15', 'POST').$linkage;
            
            }
            
            elseif ($IN->GBL('weblog_id', 'POST') == 8)
        {
            $_POST["forum_title"] = $IN->GBL('title', 'POST');
            $_POST["forum_id"] = 4;
            $_POST["forum_body"] = $IN->GBL('field_id_15', 'POST').$linkage;
            
            }

 elseif ($IN->GBL('weblog_id', 'POST') == 9)
        {
            $_POST["forum_title"] = $IN->GBL('title', 'POST');
            $_POST["forum_id"] = 8;
            $_POST["forum_body"] = $IN->GBL('field_id_15', 'POST').$linkage;
            
            }
            return;
    }
       
Greg Aker's avatar
Greg Aker
6,022 posts
16 years ago
Greg Aker's avatar Greg Aker

Moving to Extensions Forums as per your request Craig.

-greg

       

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.