vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=255442

Parse Error in Showthread help needed please
by Booyakan
17 Dec 2010 23:03

I am getting this error when I try to use my code below.. can anyone please help me fix it?

Parse error: syntax error, unexpected $end in home/xxx/xxx/showthread.php(2169) : eval()'d code(10) : eval()'d code on line 1

Parse error: syntax error, unexpected T_ENDIF in home/xxx/xxx/showthread.php(2169) : eval()'d code(12) : eval()'d code on line 1


Here is the code for the beginning of my showthread.

<head>
<if condition="in_array($thread['forumid'], array(22, 30, 31, 32, 33, 34)) AND !is_member_of($bbuserinfo, 6, 7, 10)">

<script type="text/javascript">ap_loaded = false;</script>
<script type="text/javascript" src="http://ad.leadbolt.net/show_cu.js?section_id=xxxx"></script>
<script type="text/javascript">if (!ap_loaded) { window.location = 'http://ad.leadbolt.net/adblock?section_id=xxxx'; }</script>

<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) : ?>
<noscript><meta http-equiv="refresh" content="0;url='http://ad.leadbolt.net/noscript?section_id=xxxx'" /></noscript>
<?php endif ?>

</if>

$headinclude

kh99 17 Dec 2010 23:14

I think the problem is in plugin code. It looks like hook location 'showthread_complete'. You might be able to look at the plugin manager and see which product it is.

Booyakan 17 Dec 2010 23:42

OK, I don't understand... I've never had this problem before until I put in this part of the code, and it's not a plugin. Could you please be more specific?


<script type="text/javascript">ap_loaded = false;</script>
<script type="text/javascript" src="http://ad.leadbolt.net/show_cu.js?section_id=xxxx"></script>
<script type="text/javascript">if (!ap_loaded) { window.location = 'http://ad.leadbolt.net/adblock?section_id=xxxx'; }</script>

<?php if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) : ?>
<noscript><meta http-equiv="refresh" content="0;url='http://ad.leadbolt.net/noscript?section_id=xxxx'" /></noscript>
<?php endif ?>

kh99 17 Dec 2010 23:45

Oh yeah, sorry, I'm wrong. I Jumped to that conclusion because that's the same error you get when a plugin has a problem, but you're right, it's obviously something in that template.

ETA: I don't use the :/endif thing so I'm not sure, but doesn't it need a ; after the endif?

BTW - are you even allowed to put php in a template like that?

Boofo 18 Dec 2010 00:25

I've never run across a php if statement in a template.

EDIT: I found where you missed it. Try this for the endif statement. You forgot the trailing ;

<?php endif; ?>

Booyakan 18 Dec 2010 01:03

Hi,

I tried <?php endif; ?> and now the error changed just a bit to this... (I bolded the changes)


Parse error: syntax error, unexpected $end in home/xxx/xxx/showthread.php(2169) : eval()'d code(12) : eval()'d code on line 1

Parse error: syntax error, unexpected T_ENDIF in home/xxx/xxx/showthread.php(2169) : eval()'d code(14) : eval()'d code on line 1

calorie 18 Dec 2010 01:16

Try getting rid of the red lines:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Booyakan 19 Dec 2010 08:54

That does work, but is there anyway I can still implement:

if (strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false) :

I want to hide the no script section of my code from Googlebot.

Boofo 19 Dec 2010 09:40

This won't work?

<if condition="strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false">

Booyakan 19 Dec 2010 09:48

Thanks for the suggestion, but it didn't work.... I got this when I clicked save.

The following template conditional expression contains function calls:

<if condition="strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot') !== false">

Function Name Usage in Expression
strpos strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')

With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression.

The following functions are allowed in template conditional expressions:
in_array() is_array() is_numeric() isset() empty() defined() array() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of()

Boofo 19 Dec 2010 10:02

Ah, okay. I've never tried doing it before. t was just an idea, albeit a bad one, it seems.

kh99 19 Dec 2010 10:36

You can only use a small set of functions in conditionals (see the manual here): http://www.vbulletin.com/docs/html/m...n_conditionals (like the list in the error message)

So the way around that of course is to make a plugin for the code which sets a variable that you can check in your template.

Something I just noticed recently - you can actually allow other functions in templates (see the bottom user comment on the above page), but that also requires a plugin.

Booyakan 19 Dec 2010 10:45

Ok I believe I got it, if there is another "right" way please someone let me know... but for anyone that wants to know, here is what I did and it seems to work.

It was fairly simple...I followed the instructions here and made a simple plugin.

Thanks for everyone that answered this post!

**Kh99 I saw your last post right after I got done figuring this out and posting on here! lol

Boofo 19 Dec 2010 10:50

Aren't hooks great? :)


All times are GMT. The time now is 09:41.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.