TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 25, 2024, 09:49:12 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,173
  • Total Topics: 21,219
  • Online today: 319
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online

*** Capture Post Release ***

Started by The Wizard, November 21, 2010, 01:57:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

The Wizard

CAPTURE POST
by The Wizard
November 21, 2010

Have you ever wanted to import content form your Simple Machines Forum to the Tiny portal Articles system, but can't, or don't want too because you would have to copy 1000's of pages???
This is what I was faced with, and let me tell you this is not a fun prospect. At the time of Wrighting this article there is no fast way to import content into the Tiny Portal system quickly.
Now there is - Capture Post V 1.0

How does it work overview:

1) There are two scripts Capture Post part 1, and Capture Post part 2. You must have both for the script to work.

2) The content you want to import must be on the same board.  Here is a sample flow chart to help explain this -  Fruits (Board name) - Apples (topic)
                                         - Oranges (topic)
                                          - Bananas (topic)
                                          - etc... (Topic)
                                           - etc.. (Topic)

3) Make sure there are no unwanted topics in the board; you want to grab content from. Move them somewhere else with the Simple Machines move feature.

4) *** REALLY IMPORTANT *** The Board, and anysub boards that you want to capture from the permissions must be set to guest! See the Simple Machines guide if you don't know how to do this. I hope to change this in the future, but at the time of Wrighting this article this is a must or nothing will show up!

5) Go to your Tiny Portal Article system and choose to create a PHP article. Copy and paste Capture Post 2 into your new article and save. If you were to click the preview option at this time the script will throw back the following error -  " An Error Has Occurred! Wrong value type sent to the database. Array of integers expected. (message_list) " This is GOOD! Do not panic! Look at the URL in your browser and see what page you have created - mine page was 319. Make a note of this we will need the page number in a minute.

6) Go to your Tiny Portal Article system (this should work in a block too - not tested) and choose to create a PHP article. Copy and paste Capture Post part 1 into your new article and save. Before you click on the preview we need to change a option. Find the following at the top of the script -

$P = 319; // Article page the shows the capture post
$B = 12; // Board that you want to see all the topics from

Change the 319 to the article number you created in step 5.
Go to your Forum, and get the Board number you want to capture posts from (it will be in your URL when you click on the board) Change the 12 to the board you want to capture posts from. Save the article.

7) Now this is where the fun starts! - Click on preview of the article you just save Capture Board part 1 too. You should now see a list of every topic posted in your chosen board. If you click on a topic you will be taken to a new page that shows you all the content of the first post in that topic without all the extra board stuff. In short it looks like a HTML page.

8) *** REALLY IMPORTANT *** - create a new Capture Post part 2 article for every board you use Capture Post on. I can't stress this enough. If you don't imagine eight lanes of traffic trying to get through one small one lane tunnel. By making a new Capture Post part 2 article for every board you use Capture Post on you create more lanes, and thus your users and server will not crash!   

9) Capture Post does not work with attachments at this time. I use Aeva Media, and it works fine for me. I expect you could use other Gallery scripts and they would work too. If you use another style gallery script and it works please leave a post saying so. The only way to get attachments to work would be to add a function code to your Simple Machines " SSI.php " page or create a second " SSI2.php " page. I have decided not to go in this direction as I wanted to create a script that you could use without having to change the Simple Machines source code. This way you don't have to worry about update changes, and reworking your files.

10) This script is Public Domain, and you may change it as you wish. All I ask is that you leave my username in the script.

11) audio & video will work in this script using Aeva Media. Just upload the audio or video to Aeva Media, and copy and pase the BBC embed code into any post. They use Capture Post to call the board where you have the audio topic.

Capture Post is still in it's infancy, and lacks allot of options - showing all the topics Alphabetically, Paginating (these are the two options I want bad, but at the time of wrighting this I can't seem to make it work), Plus a whole lot more I have not thought of. Hopefully with everybody's help this will change. I look forward to seeing how this script develops over the future. I am not a PHP expert in any shape, or form at best I am a third rate hack. Because of this I can't offer much in the way of support. Hopefully some of the great coders out there will help in this area.

There is no warranty given or implied.

This script has not been beta tested.

This script was designed on Tiny Portal version 1.0 RC1 using Simple Machines SMF 2.0 RC 4 and work's with Aeva Media 1.4b installed.

I know I left something out, but I just can't think of everything.... I expect you all will let me know in due course.

Capture Post Part 1

//
// Capture Post part 1
// Created by The Wizard
// November 21, 2010
// Version 1.0
//
//
// script variables for customization

$P = 319; // Article page that shows the captured post
$B = 12;  // Board that you want to see all the topics from


// ****** no need to edit past this point! Your warranty is void if modified ******

require_once('SSI.php');

$news = ssi_boardNews($B, 1000, null, null, 'array');

if (!isset($_GET['Z'])) {

foreach ($news as $topic)

{

echo'<a href="'.$scripturl. '?page='. $P .';Z='. $topic['message_id'] .'">'. $topic['subject'] .'</a></br>';

}
}

else {

$postID = (int) $_GET['Z'];

$output = ssi_fetchPosts($postID, false, 'array');

foreach ($output as $post)

{

echo '<h3> ' , $post['subject'] , '</h3>

<div> ' , $post['body'] , '</div>';

}
}


Capture Post Part 2

//
// Capture Post part 2
// Created by The Wizard
// November 21, 2010
// Version 1.0
//
//
// script variables for customization
//

// ****** no need to edit past this point! Your warranty is void if modified ******

$Z = array($_REQUEST['Z']);

$post = ssi_fetchPosts($Z, NULL, NULL);
echo $post[0]['body'], '<br />';


WillyP

Sounds like a great idea, and I'll bookmark this in case I ever need it.  Maybe with sometime this could evolve to a mod that gives you a 'Capture Topic to Article', or 'Capture Post to Article' button.

IchBin

Wizard, you need to post code using the [code][/code] tags. When you use quote tags it converts some html elements to bbc and screws up the code. You'll need to fix your post if people are going to use your code.

The Wizard

Quote from: IchBin on November 22, 2010, 06:40:36 PM
Wizard, you need to post code using the [code][/code] tags. When you use quote tags it converts some html elements to bbc and screws up the code. You'll need to fix your post if people are going to use your code.

Hello:

Thanks for catching that. I'm working on the next version of the script now, and it's going so so at the moment.