Wedge

Public area => The Pub => Off-topic => Topic started by: DirtRider on November 10th, 2010, 04:13 AM

Title: The reality of code for us [Rant]
Post by: DirtRider on November 10th, 2010, 04:13 AM
I think at times it may be hard for programmers to understand our frustration with code. Well here is a typical situation that I am experiencing with it. I am busy setting up a new forum and one of the components is to get only certain galleries showing up in a PHP block. I started looking at this 12 days ago and just cannot figure out or find the code to do this. :^^;: I have code to show random galleries but all of them not just certain ones that I require. My project is now at a standstill until I can get around this. I have posted at Noisen, SMF and Portamx and to date nothing.  :hmm:
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 10th, 2010, 08:42 AM
We've all been PHP noobs before! :p

As for Noisen -- these days I'm not reading it *at all* (unless one is lucky). Too busy on Wedge and RL.
Did Pete look into it? I'm sure he did! He's everywhere. I'm scared of him. Hopefully he's not reading this. But he's everywhere........  :ph34r:
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 10th, 2010, 09:22 AM
I am more than a PHP noob, I think I am PHP blond  :lol:. I manage to get it a few minutes back this is what I needed

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo preg_replace('~<div class="highslide-

maincontent">.*?</div>.*?</div>~', '', aeva_listItems

(aeva_getMediaItems(0, 16, 'RAND()', true, array(10)), true, 'center', 0));
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 10th, 2010, 09:50 AM
So... What you were looking for, is the code I posted in numerous places already before? I thought everyone knew of it ;)
BTW, you can do without the preg_replace I think. IIRC, this was added at a time when AeMe didn't correctly add the proper Highslide headers on non-gallery pages. Just do echo, followed by aeva_listItems, and remove the last ")".
Title: Re: The reality of code for us [Rant]
Post by: Arantor on November 10th, 2010, 12:35 PM
/mestayed away from this one, because he knows he isn't that familiar with Aeva's codebase... For now...
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 10th, 2010, 12:47 PM
Soon you'll know it better than me ;)
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 10th, 2010, 01:31 PM
This is the code I did get off noisen and have been using

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo preg_replace('~<div class="highslide-

maincontent">.*?</div>.*?</div>~', '', aeva_listItems

(aeva_getMediaItems(0, 5, 'RAND()'), false, '', 5));

I may have missed this one if it did not have a

DR THIS IS THE CODE YOU ARE LOOKING FOR tag on it  :whistle: :lol:

(http://www.terralinda72.com/000/7/8/9/11987/userfiles/image/th_arrow_down_animated.gif)

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo preg_replace('~<div class="highslide-

maincontent">.*?</div>.*?</div>~', '', aeva_listItems

(aeva_getMediaItems(0, 16, 'RAND()', true, array(10)), true, 'center', 0));

You see all code well just looks like code to me  :whistle: If it were a motorcycle part I would reconize it straight off and be able to tell you where it goes  :lol:

OMG it has taken me 12 days just to find this bit of code  :o :blush:

Code: [Select]
true, array(10)), true, 'center', 0));
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 10th, 2010, 04:26 PM
And I'm sorry about that, I just don't read posts much these days.

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo aeva_listItems(aeva_getMediaItems(0, 16, 'RAND()', true, array(10)), true, 'center', 0);

(That would be the better version.)
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 10th, 2010, 08:07 PM
 :lol: Not that serious I know how busy you guys have been so I just kept setting up other stuff but now I am ready to go. BTW while be at it how would you just exclude some galleries as my main forum I have just two of them I don't want to show in my blocks  :eheh:

Thanks for this bit of code really appreciated  :cool:
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 10th, 2010, 08:28 PM
Yes it can be done ;)
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 11th, 2010, 05:41 AM
 :whistle: :lol: I know it can be done the question is can you do it for me  :^^;: :hmm: Remember I am the blond one  :lol:
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 11th, 2010, 09:24 PM
Yeah I know, just I was typing that through my iPod so I made it quick :P Stupid keyboard... (Although I found the way to type in English, phew.)

array(10))

I believe this (in your code) says "only album #10"... You can replace it with an empty array and add, just after it, a SQL clause for eliminating certain boards.

array(), 'a.id_album NOT IN (1,2,3)')

Untested, but should work.
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 12th, 2010, 05:20 AM
So then it should look like this  :)

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo aeva_listItems(aeva_getMediaItems(0, 16, 'RAND()', true, array(), 'a.id_album NOT IN (1,2,3)') true, 'center', 0);

Posted: November 12th, 2010, 04:13 AM

Oh well I think I may have got it wrong as this is what I get  :hmm:

Parse error: syntax error, unexpected T_STRING in /home/tt/public_html/Sources/PortaMx/Class/php.php(70) : eval()'d code on line 4
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 12th, 2010, 08:12 AM
You forgot the comma after the final ")".
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 12th, 2010, 09:57 AM
Ok I now have it like this and it seems to work, thanks  :cool:

Code: [Select]
global $sourcedir;
loadLanguage('Aeva');
@include_once($sourcedir . '/Aeva-Subs.php');
echo aeva_listItems(aeva_getMediaItems(0, 5, 'RAND()', true, array(), 'a.id_album NOT IN (162,160,158,169)'), true, 'center', 0);

So now when can I start coding on Wedge for you guys  :lol:
Title: Re: The reality of code for us [Rant]
Post by: Nao on November 12th, 2010, 10:10 AM
Are you free starting Monday? :P
Title: Re: The reality of code for us [Rant]
Post by: DirtRider on November 12th, 2010, 10:16 AM
 :lol: :lol: :lol: You guys would never get finished with it I started Monday

BTW I also posted the list here http://aeva.noisen.com/support/6194/php-block-codes/msg248410/#msg248410 and here http://aeva.noisen.com/support/6194/php-block-codes/msg248410/#msg248410 So hopfully it will help some other PHP blondie like me  :whistle: :eheh: