XOOPS
News
News Index
News
Modules
Developers
Hacks
Themes
Archive
Submit News
HOME
XOOPS
About XOOPS
Why XOOPS?
XOOPS Features
Terms Of Use
Privacy Statement
License
FORUM
Board Index
Recent Topics
NEWS
THEMES
MODULES
Module @ GitHub
Old Repository
XOOPS FAQ
ACCOUNT
Login
Register
DOWNLOAD XOOPS 2.7.x
Publisher
XOOPS
Hacks
Myalbum random pic in just one line of code
Hacks
Myalbum random pic in just one line of code
slyss
11 May 2008 5:18 PM
8545 Reads
2 Comment(s)
le="color: #000000">
<?php
/****** hack by
http://www.stefanosilvestrini.com
*****/
function
getPicGallery
(
$myalbumNum
,
$cid
,
$random
) { global
$xoopsConfig
;
$db
=&
Database
::
getInstance
();
$myalbumNum
=
trim
(
$myalbumNum
); if(
$random
!=
1
)
$sql
=
"SELECT s.lid AS lid, s.ext AS ext FROM "
.
$db
->
prefix
(
'myalbum'
.
$myalbumNum
.
'_photos'
).
" s, "
.
$db
->
prefix
(
'myalbum'
.
$myalbumNum
.
'_cat'
).
" t WHERE s.cid = t.cid AND s.cid = "
.
$cid
.
" ORDER BY s.lid DESC LIMIT 1"
; else
$sql
=
"SELECT s.lid AS lid, s.ext AS ext FROM "
.
$db
->
prefix
(
'myalbum'
.
$myalbumNum
.
'_photos'
).
" s, "
.
$db
->
prefix
(
'myalbum'
.
$myalbumNum
.
'_cat'
).
" t WHERE s.cid = t.cid AND s.cid = "
.
$cid
.
" ORDER BY RAND() LIMIT 1"
;
$result
=
$db
->
query
(
$sql
);
$myrow
=
$db
->
fetchArray
(
$result
);
$object
=
"<div style='text-align: center;'>"
.
"<a href='"
.
XOOPS_URL
.
"/modules/myalbum"
.
$myalbumNum
.
"/photo.php?lid="
.
$myrow
[
'lid'
].
"'>"
.
"<img src='"
.
XOOPS_URL
.
"/uploads/thumbs"
.
$myalbumNum
.
"/"
.
$myrow
[
'lid'
].
"."
.
$myrow
[
'ext'
].
"' align='center' hspace='3' vspace='3' width='100px' />"
.
"</a>"
.
"</div>"
; return
$object
; }
and then you can add a custom PHP block with this code:
le="color: #000000">
<?php
echo
getPicGallery
(
'X'
,
'Y'
,
'Z'
);
WHERE:
- X: myalbum Number
- Y: cid number
- Z: 1 = random pic ; 0 = last inserted pic
eg:
le="color: #000000">
<?php
echo
getPicGallery
(
''
,
'1'
,
'1'
);
will display random pics from myalbum and cid = 1
Discussion into forum:
https://xoops.org/modules/newbb/viewtopic.php?post_id=288832#forumpost288832
If you need to see the original tutorial is here:
http://www.xoopsitalia.org/modules/article/view.article.php/c1/72
Feel free to visit my page for other tutorials:
http://www.stefanosilvestrini.com
bye!!!
Rating 0/5
Rating:
0
/5 (0 votes)
Voting is disabled!
Items by the same author
Flat
Threaded
Nested
Oldest First
Newest First
Refresh
Login
Username
Password
Remember me
Reset
Search
Advanced Search
Recent Comments
Re: XOOPS 2.7.1 Final Releaesed
Publisher
Mamba
07/26/2026 3:07
Re: XOOPS 2.7.1 Final Releaesed
Publisher
Yurdal
07/24/2026 20:44
Re: XOOPS 2.7.1 Final Releaesed
Publisher
Yurdal
07/24/2026 13:17
Re: XOOPS Debugbar 1.3.0 released
Publisher
Mamba
07/23/2026 0:28
Re: XOOPS Debugbar 1.3.0 released
Publisher
luciorota
07/22/2026 6:39
Donat-O-Meter
Stats
Goal:
$15.00
Due Date:
Aug 31
Gross Amount:
$0.00
Net Balance:
$0.00
Left to go:
$15.00
Categories
XOOPS
Newsletter