The reality of code for us [Rant]

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
The reality of code for us [Rant]
« on November 10th, 2010, 04:13 AM »Last edited on November 10th, 2010, 05:15 AM by DirtRider
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:
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)

Today's Logo

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: The reality of code for us [Rant]
« Reply #1, 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:

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #2, 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));

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: The reality of code for us [Rant]
« Reply #3, 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 ")".

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: The reality of code for us [Rant]
« Reply #4, on November 10th, 2010, 12:35 PM »
* Arantor stayed away from this one, because he knows he isn't that familiar with Aeva's codebase... For now...
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #6, 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:



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));

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: The reality of code for us [Rant]
« Reply #7, 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.)

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #8, 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:

Nao

  • Dadman with a boy
  • Posts: 16,082

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #10, on November 11th, 2010, 05:41 AM »Last edited on November 11th, 2010, 05:47 AM by DirtRider
 :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:

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: The reality of code for us [Rant]
« Reply #11, 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.

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #12, 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

Nao

  • Dadman with a boy
  • Posts: 16,082

DirtRider

  • All truth, in the long run, is only common sense clarified.
  • Posts: 303
Re: The reality of code for us [Rant]
« Reply #14, 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: