News:

Wondering if this will always be free?  See why free is better.

Main Menu

HELP:News integration for my website.

Started by mpglivecarlo, October 23, 2009, 06:20:58 PM

Previous topic - Next topic

mpglivecarlo

ok i got a website running now for over 2 years, at first it was going to be only a webcast page for games and had simple news publication which i made long ago in php. Some time after about 8 months i knew the website had grew more and a more robust user management was needed, so i installed SMF (love it, thx for it a good work). Now 2 years later i have 2 separate "systems" and 2 admin panels, one from smf forums and the other one for news publication and other webcast stuff.

I will upgrade to SMF 2, now what would i like to do now (the two systems are using separated DB and admin users):

1. set up or integrate the news panel to the smf so that i can set up a group of members in smf to have acces to this panel (security).

2. All news should go posted as a separate topic in a especific forum (i have an idea on how to do this) and all comments to the news will be new replys to the new topics (news)

3. integrate or "call" upon the post function used in smf that is much better than the wysiwyg using at news panel, and use that instead for creating the news.

points 1 and 3 are the most important to me, and the ones i really need help with.

I DONT know if there is any kind of mod or combitation of systems that could work, the thing is i dont want to lose the work made on template and other programmed files on website.

Any suggestions are very welcome, and thx in advance for any help.

Arantor

Without knowing the functionality you want from the news panel, it's hard to say.

However, I think you could probably do most of what you want with the SSI module - please see SSI Readme and How do I integrate SMF into my PHP coded website?

mpglivecarlo

thx for the reply ill read the information you left.

The news panel i coded it myself and it has independent accounts created in another DB, i want to integrate it to SMF accounts and admin panel.

how can i call the post wysiwyg from SMF forum in a web page coded by me, thats maybe the most difficult part i want to integrate.

Arantor

Quote from: mpglivecarlo on October 24, 2009, 02:38:22 AM
how can i call the post wysiwyg from SMF forum in a web page coded by me, thats maybe the most difficult part i want to integrate.

It's really not easy to do that, you'd be easier adding the news panel into SMF somewhere and exporting from SMF into your database.

mpglivecarlo

ok thx very much for the info i understand now how to make the integration using the boardNews function, will take time but will be just what i wanted.

i wanted to know if i can add a menu button to the current smf menu that nly is visible to a group of especific members and their "identity" checked for permission to access.

thx

Arantor

Changing the menu depends on your SMF version.

Is it literally per member, or is it based on membergroup? (The latter would be a lot easier)

mpglivecarlo

a small group of members.

Another thing, i found an article mod for smf 2, installed it and liked it really, since its a mod i think that would not be involved in ssi functions so how can i get the list of recent articles published for display on another index page?

thx

Arantor

With any mod, please request support from the the mod's author in the mod support topic.

mpglivecarlo

hey man can you help with 2 things,

1. add a menu button that will be hidden from most groups and only seen by a specific group?
2. is there a way of displaying the attachment files horizontally?

thx mate

Arantor

For the first, please start with Adding tabs to SMF 2.0.

As for displaying the attachments horizontally, I seem to recall this was discussed already on the forum and a search should cover it.

mpglivecarlo

thx for reply, i´ve been looking and searching but cant find the thumbnail code on how to do it for smf 2 rc1.2, only for smf 1.1 and some mods for smf1.4 the display template has changed since then, and there are other variables and queries included now.

if someone can help me find a topic where this is talked in smf2 be very appreciated.

Arantor

I'm not sure the Display.template.php file did change between 1.1.4 and 1.1.10, but you've indicated you're using 2.0.

I'm sure SoLoGHoST put together a post on changing the attachments area, actually, but offhand I can't find.

mpglivecarlo

yeah i want to take advantage of the new features in smf 2.0 so im making the 3dr version of my website based on it and some mods that i found, but the articles mod wass missing some stuff i needed and in support forum did not got any answers, so im making it based on the post system.

Searched with for the user you said but nothing came up for smf2 and attachment display. ill analize the mods from smf1.4 and see if i can "port" a solution to smf2.

Thx anyway for the help.


mpglivecarlo

thx for the info, ill get into it.

i got the atachments showed horizontally and seems that it does not damage theme display, but i have encountered an error that i think its already reported, that when a guest is given permission to view attachments in Firefox 3 attachments go far right and making a scrollbar because the layer (i think) displays or has no align in css.

this only happens when it is a guest, when user is registered this does not happen. ill add SS

in the modification im making im inserting attachments in a table to show in rows of 5 attachments horizontally max, and i dont get the complete error since i have aligned the table to left.

The last SS is with original display.template.php

mpglivecarlo

ok found the fix on the forum, after long search and reading.

find this in Display.template.php
// Now for the attachments, signature, ip logged, etc...
echo '
                                <div id="msg_', $message['id'], '_footer" class="attachments smalltext">';


And replace or add with:

// Now for the attachments, signature, ip logged, etc...
echo '
<div class="post floatleft" id="msg_', $message['id'], '_footer" class="attachments smalltext">';


worked in FF and IE fine for me.

mpglivecarlo

#16
OK, now i think for now this settles some of the things i needed to make posting in some specific forums to make them news forums with image attachments horizontally. I'll be working on making a specific "theme" for this boards now, but if someone wants to make horizontal attachments I'll leave here the code i made that worked for me in SMF 2 RC1.2 including the fix for guest attachment.

In Display.template.php look for line 405, or search:


// Now for the attachments, signature, ip logged, etc...
echo '
<div id="msg_', $message['id'], '_footer" class="attachments smalltext">';

// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', '; width: 100%;">';
$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'], '&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]</legend>';
}

if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a><br />';
else
echo '
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /><br />';
}


if (!$attachment['is_approved'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
echo '
(', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}

// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
</fieldset>';

echo '
</div>';
}


Change it to this:


// Now for the attachments, signature, ip logged, etc...
echo '
<div class="post floatleft" id="msg_', $message['id'], '_footer" class="attachments smalltext">';

// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
                        <hr width="100%" size="1" class="hrcolor" />
                        <div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', '; width: 100%;">
                        <table border="0" width="100%" cellpadding="3">
                        <tr>';
$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
             // increase the number of attachments variable to display
             $num_attach++;
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'], '&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]</legend>';
}

if ($attachment['is_image'])
{

if ($attachment['thumbnail']['has_thumb'])
echo '
<td valign="top"><a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" class="highslide" rel="highslide"><img src="', $attachment['thumbnail']['href'], '" alt="' , $attachment['name'] , '" id="thumb_', $attachment['id'], '" border="0" /></a><br /><div class="highslide-heading">' , $context['subject'] , '</div>';

else
echo '
<td valign="top"><img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" />';
}
                if(!$attachment['is_image']) echo'<td valign="top"><img src="' . $settings['images_url'] . '/file.gif" align="middle" alt="' . $attachment['name'] . '" border="0" /><br />';
                echo '

                    <img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;<a href="' . $attachment['href'] . '">' . $attachment['name'] . '</a></td>';

if (!$attachment['is_approved'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
                 // Set here number of horizontal attachments to display
if($num_attach==4)
                  echo '</tr><tr>';
}

// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
                      </fieldset>';

echo '
            </tr>
                      </table>
</div>';
}


If you want to change the number of images shown horizontally I've commented inside the code where to change it for your specific needs, maybe I'll see if i can code it inside the attachments menu later; maybe then I can upload it as a simple mod.

Also you will have to set an image file for the file type attachment, I've made a choppy one just for display in the SS but you can add it to the images folder of your theme and name it file.gif.

EDIT: Remember to add $num_attach variable to the global or you will get an error log from undefined variable.

mpglivecarlo

I was wondering how does smf2 manages and adds attachments to the posts, since I have a lot of news I'm going to add as posts with a script I've written so they get written directly to database. but I wanted to know how could I make the images attach to the same topic, since every news has an image.

Been searching but I think I'm not quite sure how to search for this exactly.

In simple words what i want to do:

- take a list of over 400 images and include (add) them to a specific posts without having to go topic per topic adding them inside SMF2 RC1.2

Image list "specs":
- The list is in a DB that includes an id, section (where the image should go, news, article etc.), thumb path relative to domain, and image path relative to domain.
- all images are jpg

I want to know how SMF treats the image attachments so i can write som sort of script like the one i've written to add the over 400 news and articles directly as posts in a forum.

any help is welcome thx.

Arantor

See the attachments table, that shows you the link between the filename and the message id where they will be displayed, and Display.php for how it displays them.

mpglivecarlo

i´ve seen the attachements in SMF db and tho it would seem simple i have a "problem":

- SMF stores the attachments in the attachments folder but not as the image, but as ID_file hash (i think) i really dont understand how it reconstructs the image for display.

so i would nees to look where is the function that adds the attachments and how it works to add it to the script that imports the news text.

Advertisement: