View Full Version : Attachments - Groups?
tfw2005
08-21-2007, 05:29 AM
I know this one is probably gonna be a toughie.
I am setting up an instance that will be used for articles. Each article will have 20+ images attached to it. These need to be displayed in various areas throughout the article, not just lumped at the bottom/top/side.
As of right now, Im going to tell my staff to upload, view thread in private Skin with default view of attachments, view source, copy code, paste into custom field -> show up in spot of article needed. However, this can get redundant.
Is it possible to add a designation to attachments so that you can use within a template:
Various HTML
if attachment group 1 then print $group1
Various HTML
if attachment group 2 then print $group2
Etc.
Second possibility, attachment manager shows HTML for attachments like a photobucket or imageshack situation, copy/paste. I might be able to work that out, but a grouping designation would be best, so they have to do less work to make the page look good.
OK, back to coding cave. :)
Brian
08-21-2007, 06:00 PM
What exactly would determine which "group" an attachment is in?
tfw2005
08-21-2007, 10:18 PM
Some sort of marker. Manual entry, drop down, check box. Back end CP choices, so you can create groups and variable names once. I don't really care how its done. I would be fine with a drop down offering:
Group 1
Group 2
Group 3
Group 4
Group 5
and so on.
In an attachment manager pop up, when viewing already uploaded images, you would see...
Current Attachments
shade.gif (946 Bytes) - Group 1 - |Drop down Box for Changing|
Save
Does that make sense?
Brian
08-23-2007, 12:38 PM
I like the idea of that, but I'm not sure how widely used it would be, so I might not be able to work something like that into the default code in the immediate future. I'm not sure how familiar you are with PHP, but that's something that probably would not be that hard to hack in. You would mostly just need to add a new column to the 'adv_dyna_attachments' table for the 'groupid', edit the newattachment templates to add your select menus for the groups, change the query in dynamics/newattachment.php to include the groupid, and then modify the dynamics/showentry.php file and ADV_DYNA_SHOWENTRY template so that attachments could be sorted and arranged by their group.
tfw2005
08-23-2007, 12:46 PM
I may give that a try. I'm pretty sure I understand exactly what you are saying, only reservation is that im on a live enviornment. Have to wait till dead of night to play around in case there are errors.
tfw2005
08-23-2007, 01:26 PM
Also, if I do these changes, how would the database columns be affected when upgrades are performed down the road? Im assuming file edits will need to be manually put back in, which sucks but not that bad. DB columns is a whole nother story.
Brian
08-23-2007, 03:49 PM
Any reason you can't setup a development board where you can test changes like that first? That's really the best way to go when you're adding new hacks or doing things like that yourself, and you can pretty much get an exact replica of your database and such. I believe there are instructions posted on vb.com or in their forums if you're not familiar with how to set that up.
As for upgrades... You would of course need to re-apply any file changes after upgrading. If you have any comparison programs (Beyond Compare is what I use and recommend), that makes things very easy. It could also be used to compare templates if you just copy the code from your version and the original, save them as files on your computer, and then load them up in the program to compare.
As for adding that column, I would recommend naming it something like 'twf_groupid'. That way there would not be any conflicts during an upgrade if we add a 'groupid' column at some point, and it would be easy to transfer things over to the default code.
tfw2005
09-17-2007, 06:01 PM
I like the idea of that, but I'm not sure how widely used it would be, so I might not be able to work something like that into the default code in the immediate future. I'm not sure how familiar you are with PHP, but that's something that probably would not be that hard to hack in. You would mostly just need to add a new column to the 'adv_dyna_attachments' table for the 'groupid', edit the newattachment templates to add your select menus for the groups, change the query in dynamics/newattachment.php to include the groupid, and then modify the dynamics/showentry.php file and ADV_DYNA_SHOWENTRY template so that attachments could be sorted and arranged by their group.
Hey Brian,
Working on this in a localhost enviornment. Wondering if you could give some feedback whenever not super busy.
I added tfw_groupid to the attachment table.
I added $tfw_groupid to this block of code in newattachment.php
$db->query_write("
INSERT INTO " . ADV_DYNA_TABLE_PREFIX . "attachments
(entryid, filename, userid, dateline, filesize, hasthumb, valid, extension, posthash, tfw_groupid)
VALUES (
$entryid,
'" . $db->escape_string($vba_image->_info['name']) . "',
'" . $vbulletin->userinfo['userid'] . "',
" . TIMENOW . ",
" . intval($vba_image->_info['filesize']) . ",
" . intval($vba_image->_info['hasthumb']) . ",
" . iif($vba_dyna->check_cat_perms('moderateattach'), 0, 1) . ",
'" . $db->escape_string($vba_image->_info['extension']) . "',
'" . $db->escape_string($posthash) . "',
$tfw_groupid
)
");
Added this to the newattachment template
<input type="hidden" name="tfw_groupid" value="$tfw_groupid" />
Tried to apply dropdown menus in various template locations, method or location wrong, no luck.
How and where to apply the select boxes, and exact method needed to pass the variables so that it recognizes and updates it in the DB, im a bit fuzzy.
Sorry, not so great with writing PHP from scratch, not even sure if initial steps I did are right.
Thanks!
Brian
09-18-2007, 11:32 AM
Where exactly are you trying to add the select box to choose the group?
As for passing the tfw_groupid variable, I would just add a new plugin to the 'vba_dyna_newattachment_start' location with the following code:
$tfw_groupid = $vbulletin->input->clean_gpc('r', 'tfw_groupid', TYPE_INT);
That should ensure that the variable is globalized and available anywhere within the newattachment.php file.
tfw2005
09-18-2007, 04:54 PM
Where exactly are you trying to add the select box to choose the group?
Next to the "remove button" on the attachment manager pop-up, after an attachment has been uploaded. Put another "save" button next to the "save category image" button underneath.
Brian
09-20-2007, 11:04 AM
The 'Remove' button should be located in your 'newattachment' template. Since that's used by vB as well, you would just need to wrap any new code you add in an <if condition>.
<if condition="VBA_SCRIPT == 'dynamics'">
The 'Save As Category Image' button is located in the 'adv_dyna_newattachment_set_as_row' template.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.