News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

custom action mod - eval error

Started by digit, November 18, 2009, 03:02:36 AM

Previous topic - Next topic

digit

I am using the custom action mod, and am trying to get ssi_boardNews to work with it...

I have this in my (php) action....

$array = ssi_boardNews(970, null, null, 'array');
foreach ($array as $topic)
   echo '<a href="', $topic['href'], '">', $topic['subject'], '</a><br />';

But when viewing the page that displays that (everything displays properly) I am getting the following error...

2: Invalid argument supplied for foreach()
File: /Themes/default/CustomAction.template.php(9) : eval()'d code
Line: 20

well, there is no line 20 in CustomAction.template.php - there are only 16 lines!

Any help would be greatly appreciated!

Thanks in advance.
digit

         
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

The error almost certainly won't be in that template.

What version of SMF are you using?

digit

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Install Disable Template Eval, tick the box the admin panel gives you (see the mod page for screenshots) and it'll remove the eval part so we can see where the error is.

I'm guessing that in your custom page you haven't included SSI.php though.

digit

Quote from: Arantor on November 18, 2009, 04:14:11 AM
Install Disable Template Eval, tick the box the admin panel gives you (see the mod page for screenshots) and it'll remove the eval part so we can see where the error is.

I'm guessing that in your custom page you haven't included SSI.php though.

Ok, I installed the mod - however I already had it disabled through phpmyadmin...  so after installing - it was already ticked.

Here is my entire custom action...  (and again, the BoardNews IS displaying fine, it's just throwing that error... so SSI.php is being included.)

require("/users/SSI.php");

echo '
<center>
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder">
<tr>
<td class="catbg" align="center">
CHARTER MEMBER TESTIMONIALS</td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="10" class="maintable">
<tr>
<td bgcolor="#FFFFFF"><br />
<blockquote><big><i>Here\'s what our Charter Members are saying.... </i></big><br /><br />';


$array = ssi_boardNews(970, null, null, 'array');


foreach ($array as $topic)
echo '<a href="', $topic['href'], '">', $topic['subject'], '</a><br />';


echo '
</blockquote>

</td>
</tr>
</table>';

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

digit

For the record with Disable template evaluation unchecked, the error is....

2: Invalid argument supplied for foreach()
File: /Themes/default/languages/Stats.english.php (main sub template - eval?)
Line: 20
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

It's ignoring your loop entirely and using the default for ssi_boardNews.

When you call ssi_boardNews and want to provide 'array' you have to specify all the parameters, not just most of them, which is why it's not giving you an array into $array so the foreach never runs.

The function spec for ssi_boardNews is:
Quotearray ssi_boardNews ([int $board[, int $limit[, int $start[, int $length[, string $output_method]]]]])

Meaning you'd have to call:
$array = ssi_boardNews(970, null, null, null, 'array');

(It's also why when I wrote my extreme version of ssi_boardNews, a.k.a. ssi_multiBoardNews, I deliberately didn't choose a conventional function to add it in)

digit

Yowza, it even displays the way I would have expected it to too!

I'm looking forward to trying out your ssi_multiBoardNews!   8)

Thanks a bunch!
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Well, it's with the Customizer team to approve (and while I could in theory approve it myself, it's not the done thing)

You can have a quick read up of what it provides and how it gets used here - http://www.simplemachines.org/community/index.php?topic=348439.0

digit

SIGH. I see you are focused mainly on the 2.0 branch these days. 

I don't see HOW I am going to make that leap with all my mods.  :P

Luckily there are parties interested in buying my site, so I'll leave that up to them.  ;D

Thanks again for your help.
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Quote from: digit on November 18, 2009, 05:00:24 AM
SIGH. I see you are focused mainly on the 2.0 branch these days.

??? ssi_multiBoardNews works on 1.1 too. I spent almost as long porting it back to 1.1 as I did writing it for 2.0.

QuoteI don't see HOW I am going to make that leap with all my mods.  :P

Luckily there are parties interested in buying my site, so I'll leave that up to them.  ;D

Thanks again for your help.

It depends on what mods you have and whether they've been updated or not, really.

digit

Quote from: Arantor on November 18, 2009, 05:03:53 AM
??? ssi_multiBoardNews works on 1.1 too. I spent almost as long porting it back to 1.1 as I did writing it for 2.0.

OK, I am confused...  is that the same as this?

http://www.simplemachines.org/community/index.php?topic=348439.msg2360589#msg2360589

.... where you say " (2.0 version almost complete, 1.1 not yet started)"

or is this another function, and if so, where is it?

Thanks!
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

That was 2 days ago. I hadn't written the 1.1 code at that point, I only finished it late last night.

digit

COOL, you could pm me the code if you need a beta tester  8).
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor


digit

Ok, I'll be waiting with anticipation.  :D
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

...?

It's attached to the last post!

digit

Doh!

I'm still not used to attachments being off to the right with this new theme. 

I'm using Safari.   :P

Thanks...  'will report back soon!



Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

digit

Ok, could you give me a rich example of how I would use it in a custom action?  Feeling dumb now.  :P
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor


digit

'was waiting for a response...  and didn't see this one! Thanks for responding...

Well, I'd like to display some recent posts, from certain boards, showing some avatars and attachments!  8)
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

As a *minimum* you need to tell me:
* which boards
* whether the avatars are on the left or right of the post
* whether attachments should be just a list of links, showing image thumbnails or showing the full pictures from attachments.

digit

Quote from: Arantor on November 19, 2009, 10:31:47 AM
As a *minimum* you need to tell me:
* which boards
* whether the avatars are on the left or right of the post
* whether attachments should be just a list of links, showing image thumbnails or showing the full pictures from attachments.

Boards:  287, 288, 289, 290
Avatars on right
Attachments as thumbnails. (however - I am using a now non existent attachments location mod, so I am not sure that's going to work!)

I think (or pray!)  if I can just see how you construct the array (and custom action) I can fly from there!

Thanks!
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor


$parameters = array(
  'board' => array(287, 288, 289, 290),
  'avatar' => SSI_AVATAR_RIGHT,
  'attachments' => SSI_ATTACH_THUMBNAIL,
);
ssi_multiBoardNews($parameters);

digit

VERY VERY cool - however, I am seeing no avatars, and no attachments - I am assuming because of that attachments location mod - can I pm you the URL?

Thanks!
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

digit

Hmm, also getting a ton of errors - here's my problem, but I don't know how to fix it....


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3750


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3750


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3750


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3750


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3750


8: Use of undefined constant SSI_FEED_ATOM - assumed 'SSI_FEED_ATOM'
File: /SSI.php
Line: 3739


8: Use of undefined constant SSI_FEED_RDF - assumed 'SSI_FEED_RDF'
File: /SSI.php
Line: 3733


8: Use of undefined constant SSI_FEED_RSS - assumed 'SSI_FEED_RSS'
File: /SSI.php
Line: 3727


8: Use of undefined constant SSI_AVATAR_NONE - assumed 'SSI_AVATAR_NONE'
File: /SSI.php
Line: 3692


8: Use of undefined constant SSI_ATTACH_NONE - assumed 'SSI_ATTACH_NONE'
File: /SSI.php
Line: 3646


8: Use of undefined constant SSI_FEED_NONE - assumed 'SSI_FEED_NONE'
File: /SSI.php
Line: 3459


8: Use of undefined constant SSI_ATTACH_THUMBNAIL - assumed 'SSI_ATTACH_THUMBNAIL'
File: /Themes/default/CustomAction.template.php (main sub template - eval?)
Line: 20


8: Use of undefined constant SSI_AVATAR_LEFT - assumed 'SSI_AVATAR_LEFT'
File: /Themes/default/CustomAction.template.php (main sub template - eval?)
Line: 19


I DO have this in my SSI.php....

// Don't do anything if SMF is already loaded.
if (defined('SMF'))
   return true;

define('SMF', 'SSI');
// Constants for ssi_multiBoardNews
if(!defined('SSI_ATTACH_NONE')) {
   define('SSI_ATTACH_NONE', 0);
   define('SSI_ATTACH_LINKONLY', 1);
   define('SSI_ATTACH_THUMBNAIL', 2);
   define('SSI_ATTACH_INLINE', 3);
   define('SSI_AVATAR_NONE', 0);
   define('SSI_AVATAR_LEFT', 1);
   define('SSI_AVATAR_RIGHT', 2);
   define('SSI_FEED_NONE', 0);
   define('SSI_FEED_RSS', 1);
   define('SSI_FEED_ATOM', 2);
   define('SSI_FEED_RDF', 4);
}
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Ahhh, I know why you're getting the errors. You're getting those because you're including SSI.php from inside SMF itself.

Move the second block you point out above the first.

digit

Like this?

// Constants for ssi_multiBoardNews
if(!defined('SSI_ATTACH_NONE')) {
   define('SSI_ATTACH_NONE', 0);
   define('SSI_ATTACH_LINKONLY', 1);
   define('SSI_ATTACH_THUMBNAIL', 2);
   define('SSI_ATTACH_INLINE', 3);
   define('SSI_AVATAR_NONE', 0);
   define('SSI_AVATAR_LEFT', 1);
   define('SSI_AVATAR_RIGHT', 2);
   define('SSI_FEED_NONE', 0);
   define('SSI_FEED_RSS', 1);
   define('SSI_FEED_ATOM', 2);
   define('SSI_FEED_RDF', 4);
}


define('SMF', 'SSI');


I am still getting the errors.
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Huh? The errors are caused by the constants not being defined, and with that they should be being defined :-/

digit

#29
Yep, I was still getting the errors...

However, I just tried adding this...

// Constants for ssi_multiBoardNews
if(!defined('SSI_ATTACH_NONE')) {
   define('SSI_ATTACH_NONE', 0);
   define('SSI_ATTACH_LINKONLY', 1);
   define('SSI_ATTACH_THUMBNAIL', 2);
   define('SSI_ATTACH_INLINE', 3);
   define('SSI_AVATAR_NONE', 0);
   define('SSI_AVATAR_LEFT', 1);
   define('SSI_AVATAR_RIGHT', 2);
   define('SSI_FEED_NONE', 0);
   define('SSI_FEED_RSS', 1);
   define('SSI_FEED_ATOM', 2);
   define('SSI_FEED_RDF', 4);
}


To the custom php action, and voila! My attachments are working, and my avatars are ALMOST working LOL...

But it is showing avatar URL's like this (getting a broken icon)

http://www.mysite.com/index.php?action=dlattach;attach=379267;type=avatar

When my avatar urls look like....

http://www.mysite.com/avataruploads/avatar_35220.png

I am also now getting a bunch of other errors like these...

8: Undefined index: id_thumb
File: /users/SSI.php
Line: 3683

8: Undefined index: kilobyte
File: /users/SSI.php
Line: 3677

Here is what I did with the custom action....

require("/users/SSI.php");

echo '
<center>
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder">
<tr>
<td class="catbg" align="center">
RECENT POSTS</td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="10" class="maintable">
<tr>
<td bgcolor="#FFFFFF"><br />
<blockquote>';


// Constants for ssi_multiBoardNews
if(!defined('SSI_ATTACH_NONE')) {
define('SSI_ATTACH_NONE', 0);
define('SSI_ATTACH_LINKONLY', 1);
define('SSI_ATTACH_THUMBNAIL', 2);
define('SSI_ATTACH_INLINE', 3);
define('SSI_AVATAR_NONE', 0);
define('SSI_AVATAR_LEFT', 1);
define('SSI_AVATAR_RIGHT', 2);
define('SSI_FEED_NONE', 0);
define('SSI_FEED_RSS', 1);
define('SSI_FEED_ATOM', 2);
define('SSI_FEED_RDF', 4);
}

$parameters = array(
  'board' => array(35,9),
  'avatar' => SSI_AVATAR_LEFT,
  'attachments' => SSI_ATTACH_INLINE,
);
ssi_multiBoardNews($parameters);
echo '
</blockquote>

</td>
</tr>
</table>';






Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Well, the kilobyte index is something I assumed naively would be in 1.1 the same as it is in 2.0 - but isn't. You'll find $txt['kilobyte'] in SSI.php, which should be replaced with $txt['smf211'].

The id_thumb issues are caused by:
$attachment['thumbnail'] = $attach_single['id_thumb'] == 0 ? false : array(
'href' => $scripturl . '?action=dlattach;topic=' . $attach_single['ID_TOPIC'] . '.0;attach=' . $attach_single['id_thumb'] . ';image',


Which should be:
$attachment['thumbnail'] = $attach_single['ID_THUMB'] == 0 ? false : array(
'href' => $scripturl . '?action=dlattach;topic=' . $attach_single['ID_TOPIC'] . '.0;attach=' . $attach_single['ID_THUMB'] . ';image',



As for the other error, curious. I completely forgot to test for users who use custom avatar directories.

* Arantor goes back to figure out how to make that work.

digit

#31
Thanks - but I'm still getting broken icons for the avatars.  :P  (but ALL the errors went away - YAY!)

Also,  is there a way within the array to define how many posts to display?

Thanks for the help, this is going to be VERY useful and cool once I (or we) work the kinks out.
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

You will do until I figure out why it's not working. Though it 'should' since it does actually do a check against the relevant paths, I just never tested that since I got the code directly from Display.php.


You can set how many threads it examines with $parameters['limit'] but it will only ever retrieve the first post from each topic, just like ssi_boardNews does.

digit

BTW - I am also looking forward to your OpenSearch integration...  I tried Sphynx, but found the results wonky.
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

OpenSearch isn't a search backend.

It's a hook to your browser and other systems how they can search your forum.

digit

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

* Arantor is confused why everyone calls it Sphynx when it's spelt Sphinx based on it being short for SQL phrase index.

If you're getting funny results from Sphinx, means something isn't configured right, usually.

digit

Sphinx...   8)

BTW - I just tried your ssi_multiBoardNews with other boards (and a limit of 100)... and noticed that it IS displaying avatars that are server stored and selected, but not uploaded avatars.

Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

Arantor

Ah so it's just related to uploaded avatars where there's a custom avatar directory.

Thanks, I think I know where to look now...

Advertisement: