Hallo, Gast! (Registrieren)

Letzte Ankündigung: MyBB 1.8.37 veröffentlicht (04.11.23)


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste
Latest Attachment Gallery
#11
Ich werde das programmieren.
[Bild: banner.png]

Bitte die Foren-Regeln beachten und im Profil die verwendete MyBB-Version angeben.
Zitieren
#12
Das wär goil :-)
Zitieren
#13
Ersetze das:
PHP-Code:
function atchgallery()
{
    global 
$mybb$templates$atchgallery$db$collapsed$collapsedimg$theme$header;
    
    
$forum $mybb->settings['atchgalleryforum'];
    
$max $mybb->settings['atchgallerymax'];
    
$maxperrow $mybb->settings['atchgallerymaxperrow'];
    
    if((
$mybb->settings['showatchgallery'] != 'off') && (is_numeric($forum)) && (is_numeric($max)))
    {
        
$i=0;
        
$query $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE thumbnail != '' ORDER BY aid DESC");
        while(
$i $max && $rows $db->fetch_array($query))
        {
            if(
$forum == -1)
            {
                
$i++;
                
$array[$i][aid] = $rows['aid'];
                
$array[$i][pid] = $rows['pid'];
                
$array[$i][thumbnail] = $rows['thumbnail'];
            }
            else
            {
                
$checkquery $db->simple_select(TABLE_PREFIX."posts""fid""pid = '" $rows['pid'] . "' AND fid = '" $forum "'");
                
$c $db->fetch_array($checkquery);
                if(
is_array($c))
                {
                    
$i++;
                    
$array[$i][aid] = $rows['aid'];
                    
$array[$i][pid] = $rows['pid'];
                    
$array[$i][thumbnail] = $rows['thumbnail'];
                }
            }
        }
        
        
//only show on forum index
        
if($mybb->settings['atchgalleryglobal'] == '1')
        {
            
$visible = (basename($_SERVER["PHP_SELF"]) == "index.php" || basename($_SERVER["PHP_SELF"]) == "portal.php");
        }
        
//only show on THE forum specified to pull attachments from
        
else if($mybb->settings['atchgalleryglobal'] == '-1')
        {
            if((
basename($_SERVER["PHP_SELF"]) == "forumdisplay.php" && $mybb->input['fid'] == $forum) || $forum == '-1')
            {
                
$visible TRUE;
            }
            elseif(
basename($_SERVER["PHP_SELF"]) == "showthread.php")
            {
                
$thread get_thread($mybb->input['tid']);
                if(
$forum == $thread['fid'])
                {
                    
$visible TRUE;
                }
            }
        }
        else
        {
            
$visible TRUE;
        }
        
        if((
$i 0) && $visible)
        {
            
$count 0;
            foreach(
$array as $thumbs)
            {
                
$height $mybb->settings['attachthumbh']+10;
                
$count++;
                
$i--;
                if(
$mybb->settings['atchgallerylink'] == 'no')
                {
                    
$link "attachment.php?aid=" $thumbs[aid];
                }
                else if(
$mybb->settings['atchgallerylink'] == 'yes')
                {
                    
$post get_post($thumbs[pid]);
                    
$link "showthread.php?tid=" $post['tid'] . "&pid=" $thumbs[pid] . "#pid" $thumbs[pid];
                }
                
                
//if there is a thumbnail, that means its a big attachment!
                
$image = ($thumbs[thumbnail]=='SMALL') ? 'aid' 'thumbnail';

                
$rowwidth 100/$maxperrow;
                
$thumbnails .= "<td class=\"trow1\" style=\"text-align: center; width: " $rowwidth "%;\">\n";
                
$thumbnails .= "\t<a href=\"" $link "\" target=\"_blank\"><img src=\"attachment.php?" $image "=" $thumbs[aid] . "\" class=\"attachment\" alt=\"\"></a>\n";
                
$thumbnails .= "</td>\n";
                
                if((
$count == $maxperrow) && ($i != 0))
                {
                    
$thumbnails .= "\n</tr>\n<tr style=\"height: " $height "px;\">";
                    
$count 0;
                }
            }
            
            
$name $mybb->settings['atchgalleryname'];
            
//if the collapse button is enabled
            
if($mybb->settings['atchgallerycollapse'] == 'on')
            {
                
$collapse "
                <div class=\"expcolimage\">
                    <img src=\""
.$theme['imgdir']."/collapse".$collapsedimg[$cid].".gif\" id=\"atchgallery_id_img\" class=\"expander\" alt=\"[-]\" />
                </div>"
;
            }
            eval(
"\$atchgallery = \"".$templates->get('atchgallery')."\";");
            
$header str_replace('{atchgallery}'$atchgallery$header);
        }
    }

durch:
PHP-Code:
function atchgallery()
{
    global 
$mybb$templates$atchgallery$db$collapsed$collapsedimg$theme$header;
    
    
$forum $mybb->settings['atchgalleryforum'];
    
$max $mybb->settings['atchgallerymax'];
    
$maxperrow $mybb->settings['atchgallerymaxperrow'];
    
    if((
$mybb->settings['showatchgallery'] != 'off') && (is_numeric($max)))
    {
        
$i=0;
        
$query $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE thumbnail != '' ORDER BY aid DESC");
        while(
$i $max && $rows $db->fetch_array($query))
        {
            if(
$forum == -1)
            {
                
$i++;
                
$array[$i][aid] = $rows['aid'];
                
$array[$i][pid] = $rows['pid'];
                
$array[$i][thumbnail] = $rows['thumbnail'];
            }
            else
            {
                
$checkquery $db->simple_select(TABLE_PREFIX."posts""fid""pid = '" $rows['pid'] . "' AND fid IN (" $forum ")");
                
$c $db->fetch_array($checkquery);
                if(
is_array($c))
                {
                    
$i++;
                    
$array[$i][aid] = $rows['aid'];
                    
$array[$i][pid] = $rows['pid'];
                    
$array[$i][thumbnail] = $rows['thumbnail'];
                }
            }
        }
        
        
//only show on forum index
        
if($mybb->settings['atchgalleryglobal'] == '1')
        {
            
$visible = (basename($_SERVER["PHP_SELF"]) == "index.php" || basename($_SERVER["PHP_SELF"]) == "portal.php");
        }
        
//only show on THE forum specified to pull attachments from
        
else if($mybb->settings['atchgalleryglobal'] == '-1')
        {
            if((
basename($_SERVER["PHP_SELF"]) == "forumdisplay.php" && stripos(','.$forum.','','.$mybb->input['fid'].',') !== false) || $forum == '-1')
            {
                
$visible TRUE;
            }
            elseif(
basename($_SERVER["PHP_SELF"]) == "showthread.php")
            {
                
$thread get_thread($mybb->input['tid']);
                if(
stripos(','.$forum.','','.$thread['fid'].',') !== false)
                {
                    
$visible TRUE;
                }
            }
        }
        else
        {
            
$visible TRUE;
        }
        
        if((
$i 0) && $visible)
        {
            
$count 0;
            foreach(
$array as $thumbs)
            {
                
$height $mybb->settings['attachthumbh']+10;
                
$count++;
                
$i--;
                if(
$mybb->settings['atchgallerylink'] == 'no')
                {
                    
$link "attachment.php?aid=" $thumbs[aid];
                }
                else if(
$mybb->settings['atchgallerylink'] == 'yes')
                {
                    
$post get_post($thumbs[pid]);
                    
$link "showthread.php?tid=" $post['tid'] . "&pid=" $thumbs[pid] . "#pid" $thumbs[pid];
                }
                
                
//if there is a thumbnail, that means its a big attachment!
                
$image = ($thumbs[thumbnail]=='SMALL') ? 'aid' 'thumbnail';

                
$rowwidth 100/$maxperrow;
                
$thumbnails .= "<td class=\"trow1\" style=\"text-align: center; width: " $rowwidth "%;\">\n";
                
$thumbnails .= "\t<a href=\"" $link "\" target=\"_blank\"><img src=\"attachment.php?" $image "=" $thumbs[aid] . "\" class=\"attachment\" alt=\"\"></a>\n";
                
$thumbnails .= "</td>\n";
                
                if((
$count == $maxperrow) && ($i != 0))
                {
                    
$thumbnails .= "\n</tr>\n<tr style=\"height: " $height "px;\">";
                    
$count 0;
                }
            }
            
            
$name $mybb->settings['atchgalleryname'];
            
//if the collapse button is enabled
            
if($mybb->settings['atchgallerycollapse'] == 'on')
            {
                
$collapse "
                <div class=\"expcolimage\">
                    <img src=\""
.$theme['imgdir']."/collapse".$collapsedimg[$cid].".gif\" id=\"atchgallery_id_img\" class=\"expander\" alt=\"[-]\" />
                </div>"
;
            }
            eval(
"\$atchgallery = \"".$templates->get('atchgallery')."\";");
            
$header str_replace('{atchgallery}'$atchgallery$header);
        }
    }

Dann kannst du anstatt einer fid mehrere angeben. Du musst sie durch Kommas trennen.
[Bild: banner.png]

Bitte die Foren-Regeln beachten und im Profil die verwendete MyBB-Version angeben.
Zitieren
#14
Hallo Dragon,

erstmal vielen Dank. Ich hatte erst heute abend etwas Zeit das Plugin zu patchen. Leider lässt sich das Forum wegen SQL-Fehlers dann nicht mehr aufrufen:

MySQL error: 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
Query: SELECT fid FROM mybb_posts WHERE pid = '6995' AND fid IN (19)'


Fehlt da ein Hochkomma vor dem SELECT ? Hab leider im Moment leider selbst keine Zeit im Code zu suchen.

Schöne Woche
Zitieren
#15
Da war ein ' zu viel. Ich habe den Code oben ausgebessert. Funktioniert es jetzt?
[Bild: banner.png]

Bitte die Foren-Regeln beachten und im Profil die verwendete MyBB-Version angeben.
Zitieren
#16
Das hätte ich wahrscheinlich ohne Grippe auch gefunden, sorry.

Funktioniert jetzt, aber ohne Beachtung der Userrechte... d. h. er beschränkt die Anzeige nicht auf das einzelne Forum, sondern schmeisst aus den angegebenen Foren die Bilder zusammen.

Dann stimmen aber die Zugriffsrechte nicht mehr, wir haben nämlich einen geschlossenen Forumsbereich.

Es sollte so sein, dass nur Bilder nur eines, nämlich jeweils des angezeigten Forums, angezeigt werden.

Gruss
Zitieren
#17
Hi ihr Meistercoder:

Wieviel aufwand ist es, das PHP-Script so zu ändern, dass es Zufallsbilder wählt und nicht die letzten.
Wäre ein zusätzliches Template denkbar mit nur einem Bild? Unabhängig vom bisherigen Template?
Ich suche sowas für das Portal. Existiert evtl. ein anderes Plugin irgendwo dafür?

Danke Big Grin
Zitieren
#18
Mit der Programmierung des Zufalls kenne ich mich nicht aus. Wink
Du willst noch so ein Plugin, dass nur ein Bild anzeigt und beim Portal zu sehen ist?
[Bild: banner.png]

Bitte die Foren-Regeln beachten und im Profil die verwendete MyBB-Version angeben.
Zitieren
#19
Dragon schrieb:Du willst noch so ein Plugin, dass nur ein Bild anzeigt und beim Portal zu sehen ist?

Ja, richtig. Über eine Bildergallerie ist ja schon viel gepostet worden. Aber ich brauche keine große Gallerie. Ich (wir) möchte auf dem Portal und/oder Index eine kleine Box anbringen in der ein zufällig gewähltes Attachment-Bild angezeigt wird. Ähnlich wie es zB im MKPortal möglich ist. Ich möchte aber nicht ein extra Portal von einem Drittanbieter installieren und suche jetzt nach Bordmitteln. Wie zB auch einen Blog.

Technisch stelle ich mit das so vor:
Im PluginPHP ist eine SQL-Abfrage drin. Hab ich schon gesehen. Die ist nach Datum sortiert. Wenn mann jetzt eine Zufallszahl von 1 bis <Anzahl der Attachments> generiert und einfach ein Attach damit rauspickt, wäre das doch mit machbar...?
Ich habe keine Plan von PHP. Sonst würde ich mich selber dransetzen Smile
Auch ein Template einzubinden in das vorhandene PHP müsste doch kein Problem sein. da würde ich mich sogar selber dran trauen.
Zitieren
#20
Das mit der Zufallszahl ist nicht so einfach. Die ID muss es ja auch geben und sie sollte ein Bild sein. Daher geht das nicht so einfach.
[Bild: banner.png]

Bitte die Foren-Regeln beachten und im Profil die verwendete MyBB-Version angeben.
Zitieren


Möglicherweise verwandte Themen…
Thema Verfasser Antworten Ansichten Letzter Beitrag
  Latest Posts on sidebar MyBB.de Bot 30 7.682 01.03.2020, 01:47
Letzter Beitrag: Exodus
  Latest Threads Ticker MyBB.de Bot 0 790 29.11.2018, 13:05
Letzter Beitrag: MyBB.de Bot
  Latest Posts on Profile MyBB.de Bot 0 1.299 03.01.2017, 16:15
Letzter Beitrag: MyBB.de Bot
  Better Latest Threads MyBB.de Bot 0 1.303 30.06.2016, 17:40
Letzter Beitrag: MyBB.de Bot
  Latest Visitors on Profile MyBB.de Bot 0 1.795 27.11.2014, 19:50
Letzter Beitrag: MyBB.de Bot