Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [split] Coding Question
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
[split] Coding Question
I am trying to make an xthreads forum where I can utilise the myBb attachment functionality so I can have banner headers on my forum using images pulled from the threads. I can't work out how to make the x threads attachments do it on forum display. If I try and do it on forumdisplay threadlist then I cannot get it to work. So I tried forumdisplay - no luck.

Anyway, I have discovered that by adding the forum prefix to default template copies of postbit_attachments and post_attachments I can rewrite the text and things in the attachment uploads box and exclude the attachment from showing in the main post. However, I want to restrict the attachments to only images and the KB size to 30kb, but ONLY in that one forum. Is there any way to do this? Code edits are ok I guess, as long as I can use the full attachments functionality elsewhere on other forums on my board.

Later Edit: I have been doing some more checks and I now see that if a user (member or guest) uses the post reply or preview posts buttons in this forum then they also have the option to upload attachments.

This is not really good, as the replies are to work as comments and the first post to be the only one with the rights to upload (see requirement for attaching images via myBB above). Any sugggestions on how to make this option to attach ONLY show on the first post and not on the replies?


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 06-05-2010 09:18 AM by leefish.)
06-05-2010 05:40 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: [split] Coding Question
I'm guessing you want to have some slideshow of images at the top of the forumdisplay page, sourced from all? the threads in the forum which have images attached?
I don't think XThreads can do it unfortunately, since it still goes by how MyBB displays threads, so if you want two separate groups of stuff (slideshow and a threads list, kept in separate locations) you're probably out of luck there.

If you have a MyBB plugin which can display attached images, then I guess it could be possible to restrict attachment types/sizes for a specific forum.  Is this what you want?

My Blog
06-05-2010 09:14 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: [split] Coding Question
I have several plug ins that do this for me - I have one by JeffChan where I can specify which forum the images are pulled from, but it pulls ALL the images, in thread order. Some of my posts have 4 images in - and I only wanted to show 6 pics in the banner. I was going to use Jeffs plug in for the forum display. I would work around the calling all the images by having only ONE MyBB image attachment in a thread, the rest being Xthreads.

I have another excellent plug in by Rateu which gets ONLY the first attachment from the attached images list in a thread and displays that. I use that right now on my portal page. I prefer the coding on Rateus plug in as it gets only the first image attachment, but it would be nice to have the forum display option like in Jeffs.

Really what I am looking for is that the plug ins I have call the attachments from the Xthread attachments database rather than the myBB attachments database. It seems a terrible waste of space to not be able to use the same image twice. I can see in the Db that there is a table for the x threads images, what I can't work out is how to get them into the display format. If can get the images showing on portal and/or index and/or source forum and select from one or more forums then most of my problem is solved - I just move the attachments set up for my downloads forum across to Xthreads.  Heck, my entire board I guess.

I attached the files I am using.


Attached File(s)
.zip  Gallery.zip (Size: 6.6 KB / Downloads: 432)


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 06-05-2010 09:47 AM by leefish.)
06-05-2010 09:35 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: [split] Coding Question
I haven't checked, but if you want to just pull from XThreads instead of MyBB's attachment system, you could probably do the following edits (IDK if they work or not).

For Rateu's plugin, find:

PHP Code:
1
2
3
4
5
6
7
8
9
10
		$query = $db->query("
			SELECT a.*, p.fid AS pfid, p.tid AS ptid, p.pid AS ppid, t.*
			FROM ".TABLE_PREFIX."attachments a
			LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
			LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
			WHERE t.visible=1 AND a.thumbnail != '' AND a.thumbnail != 'SMALL' AND t.fid IN ('".implode("','", $mnlatatgal_tid_array)."')
			GROUP BY a.pid
			ORDER BY a.aid DESC
			LIMIT $mnlatatgal_num
		");

Replace with

PHP Code:
1
2
3
4
5
6
7
8
		$query = $db->query("
			SELECT a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, t.*
			FROM ".TABLE_PREFIX."xtattachments a
			LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
			WHERE t.visible=1 AND t.fid IN ('".implode("','", $mnlatatgal_tid_array)."')
			ORDER BY a.aid DESC
			LIMIT $mnlatatgal_num
		");

Find:

PHP Code:
			$mnlag_datetime = my_date($mybb->settings['dateformat'], $mnlag['dateuploaded']).' '.my_date($mybb->settings['timeformat'], $mnlag['dateuploaded']);
			$mnlag_att_thumb = "attachment.php?thumbnail=".intval($mnlag['aid']);

Replace with:

PHP Code:
			$mnlag_datetime = my_date($mybb->settings['dateformat'], $mnlag['uploadtime']).' '.my_date($mybb->settings['timeformat'], $mnlag['uploadtime']);
			$mnlag_att_thumb = xthreads_get_xta_url($mnlag).'/thumb160x120';

(replace "thumb160x120" with your dimensions)

Jeff's looks more difficult to do


My Blog
06-05-2010 10:20 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #5
RE: [split] Coding Question
(06-05-2010 05:40 AM)leefish Wrote:  Later Edit: I have been doing some more checks and I now see that if a user (member or guest) uses the post reply or preview posts buttons in this forum then they also have the option to upload attachments.

Do you mean the XThreads attachments?

06-05-2010 10:27 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #6
RE: [split] Coding Question
(06-05-2010 10:27 AM)RateU Wrote:  
(06-05-2010 05:40 AM)leefish Wrote:  Later Edit: I have been doing some more checks and I now see that if a user (member or guest) uses the post reply or preview posts buttons in this forum then they also have the option to upload attachments.

Do you mean the XThreads attachments?

I mean the MyBB attachments.


[Image: leelink.gif]
MYBB1.6 & XThreads
06-05-2010 10:15 PM
Visit this user's website Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: [split] Coding Question
Reporting back - yes it works! But, it has lost the ability to select only the first attachment in a post.

Using my current settings (pull last 5 attachments from forum 30) with the MyBB attachments version would give me five attachment thumbnails from 5 posts.

Using the same settings in the Xthreads version gives me five attachment thumbnails from 3 posts.  This is because one of the posts has three attachment thumbnails.

I am looking at the differences in the two code sets posted above, and I see that in Rateus code there is a line to group by pid, then to pull the attachments. I have no pid in the Zinga version, but I see that Zinga is using the threads table to join to in the database.

So, I added a line in the code (line6):

Code:
1
2
3
4
5
6
7
8
9
			$query = $db->query("
			SELECT a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, t.*
			FROM ".TABLE_PREFIX."xtattachments a
			LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
			WHERE t.visible=1 AND t.fid IN ('".implode("','", $mnlatatgal_tid_array)."')
			GROUP BY a.tid
			ORDER BY a.aid DESC
			LIMIT $mnlatatgal_num
		");


I tested it and it worked perfectly. My next challenge is to work out how to get this to show on the forum display. I do think that this is a plug in that many other users would like to have and I would like to ask Rateu if he would consider posting it as a plug in here on MyBBhacks? I can't post it as it is not my plugin.



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 06-05-2010 10:56 PM by leefish.)
06-05-2010 10:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #8
RE: [split] Coding Question
And plodding slowly on, I have got this to display on forumdisplay, but on ALL forums. This was not my master plan.... My idea was to have multiple copies of this plug in...and to specify the forum id it showed on. That way EACH forum I have attachments in would have a banner of their own as specified from the ACP.  I got it to show on all forums by adding this to the code at line 172:

Code:
		elseif($GLOBALS['mybb']->settings['mnlatatgal_dsp'] == 'forum')
	{
		$GLOBALS['plugins']->add_hook('forumdisplay_start', 'mnlatatgal_run');


and adding the option "Forum" to the display settings. Now I would like to have this show on JUST the forum that I am pulling the attchments from - I am looking on the internet for "WHERE" statements as that seems logical.

Also, I ( rather belatedly) see that Rateu has asked that this plug in is not to be redistributed. I hope that this does not count as redistributing Erf



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 06-06-2010 01:10 AM by leefish.)
06-06-2010 01:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #9
RE: [split] Coding Question
In whatever pages do you want it be displayed, Lee? Do you want it in forumdisplay only, but not in portal?

(06-06-2010 01:09 AM)leefish Wrote:  Also, I ( rather belatedly) see that Rateu has asked that this plug in is not to be redistributed. I hope that this does not count as redistributing Erf

Smile I put that "license" when creating the plugin, when my forum still a live. I have my own reason for that (I don't want to create another debate about paid Vs free plugin). I hope you know in which side I stand, Lee.

(06-05-2010 10:53 PM)leefish Wrote:  I can't post it as it is not my plugin.

My forum has been closed now. So, you can do whatever you want with it Smile But, keep it free.

06-06-2010 07:26 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #10
RE: [split] Coding Question
Hi Rateu, I have it so that it displays on portal or index or portal and index or all forums. That is the next thing - I would like to be able to have the banner show ONLY on the forum the data is from. I think it is because it is part of the header - Im not really sure what to do next.

What I am looking to do is to pull the images from one forum and have that as a display at the top of the page on the forum display. But I only want it on the forum its related to. If I am looking at my forum display in a forum about css in a different part of the board then I dont want a load of pictures of sims teapots across the top - its absurd Smile.

It would be good if I could make this a stand alone type file where the file has to be put into the template. This version is good for single banners, but say I wanted a banner about finds, and another about downloads? I want to put them on the portal page but not stacked on top of each other.

I should add that I am perfectly ready to have several versions of this in my plug ins folder so that I can have banners in more than one forum. Indeed, that is my plan.

My Goal:
Have a banner on the portal that is for a certain forum - I can change the forum from the ACP if it gets boring (current plug in does this)

Have a banner on a single forum that is JUST for that forum (puzzling over this now)

Have options to place the banners in different areas of the portal - as a header. a footer, a side bar etc. This would mean a plug in where I paste the plugin name eg {$myplugin} into a template.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 06-06-2010 08:21 AM by leefish.)
06-06-2010 07:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: