Jump to content

Forum Image


OblivionNW

Recommended Posts

Hey all, I am building a main page that fetches data (news) from my forum, and I would like to be able to add a sort of 'forum image' database column, and a way to upload a file that I could fetch with my posts from the database.

What I mean by this is if I have several forums, one called 'general discussion', one called 'suggestions', one called 'support' I would like to be able to upload an image for each type of forum, so that way on the main page, users will be able to easily distinguish between the content of each story/post. Also of course for a more aesthetic layout. 

Link to comment
Share on other sites

From what you tried to explain, the pages or blogs application could may fit a lot better your needs.
The image you showed is a template of a blog...

If I understood you correctly there 3 options:

  1. As @bfarber mentioned, you can write a hook, which is the most comfortable and "best practice" solution
  2. You can write raw html into the forum post, adding a hidden tag with an id and include the forum image can be queried from the fetch
  3. You use the api and determine on your external page the forum id and set based on that the image, if you always want to show the same image per forum.

 

Greetings

Link to comment
Share on other sites

On 12/15/2016 at 8:23 AM, bfarber said:

This is available:

But it uses font-awesome instead of uploaded images.

Alternatively you can hook into the forum ACP controller classes to add the form field to upload the image, and then adjust the front end templates to display it.

Is there a tutorial on how to add a file upload to when creating the forum? I think that would be somewhat complex to handle moving that file to a proper location / storing it, associating it to that forum, etc

Link to comment
Share on other sites

Adding the file upload field will require writing a plugin. Actually moving the file won't be hard because the form helper will do it all for you. Most likely the plugin will need to add the form helper field, then assign the value to the forum active record object.

// Adding the form field will look similar to the following
// In an ideal world you would create a new file storage extension for this, but if you are just throwing together something for your own site you can probably get away with reusing one, such as core_Theme
$form->add( new \IPS\Helpers\Form\Upload( 'forum_icon', NULL, TRUE, array( 'image' => TRUE, 'minimize' => FALSE, 'maxFileSize' => NULL, 'storageExtension' => 'core_Theme' ) ) );

// Then when processing the values you would do something like
$forum->forum_icon = (string) $values['forum_icon'];

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...