PDA

View Full Version : plugin not working?


lukemax
03-30-2008, 07:29 PM
Im trying to create a hook out of this page
http://lvasp.com/providers_hook.php
So I add the PHP include like the manual says,
I'm trying to import it into
http://lvasp.com/forum/providers.php
But when I enable the hook (screenshot) the board breaks and I have to disable it.
(attatched is also the source code of the hook.

Any ideas...
Thanks...

Dismounted
03-31-2008, 05:15 AM
As you are coding your own custom page, you can put the PHP code directly into the providers.php file. There is no need to use hooks.

lukemax
03-31-2008, 02:12 PM
How do I do that. I used this (https://vborg.vbsupport.ru/showthread.php?t=62164&highlight=vbulletin+powered+page) tutorial so heres the code for my php page.

Opserty
03-31-2008, 02:30 PM
What do you mean "How do you do it?", you need to put the PHP in the PHP file (under the START MAIN SCRIPT section).

I'm not sure how else to explain it.

lukemax
03-31-2008, 06:46 PM
Man (I think I'm missing something here)
I took the code from providers_page.php and copied it into line 37 and I got "Sorry, page unavailable" (is that right?
Thanks...

Opserty
03-31-2008, 08:01 PM
Sorry, page unavailable

Doesn't sound like a vBulletin/PHP related error.

lukemax
03-31-2008, 08:36 PM
But, placing the code there (inside providers.php on line 37 should work?) Why does it work without it?
Thanks

Lynne
03-31-2008, 08:39 PM
Perhaps you need to figure out why you are getting the "Page Unavailable" message first. Do you have the permissions set correctly on the file - 644?

lukemax
04-01-2008, 12:50 AM
ok, I created this hook, (1st screenshot) and in it created the $providers variable like in your tutorial, but when I include the variable ($providers in the second screenshot) in a template, the board breaks, till I disable the hook. I can even go straight the the hook
http://www.lvasp.com/providers_hook.php
Thanks

What is the correct way to do this?

Boofo
04-01-2008, 12:52 AM
Try {$providers}

lukemax
04-01-2008, 01:53 AM
no, that didn't work either, right now since I have the plugin disabled http://www.lvasp.com/forum/providers.php
but when I enable it, it doesn't work.
Thanks for the help.

Boofo
04-01-2008, 02:04 AM
I donlt see $providers in providers_hook.php (https://vborg.vbsupport.ru/attachment.php?attachmentid=78006&d=1206992862). Where is that varibale at?

lukemax
04-01-2008, 03:13 AM
oh, I thought I was supposed to output that php page to a variable (see the hook I made) Then use that variable in the custom template I made (other screenshot) Lastly include this new template in providers.php.

Is this easy and do I make sence?
Thanks again

Dismounted
04-01-2008, 04:41 AM
Why do you need the hook? You only need that data in your providers.php page, so you can place the code into that page directly.

Opserty
04-01-2008, 11:52 AM
I think you are misunderstanding the concept of the Hooks & Plugins system. The system was purely put in place by vBulletin in order to make it easier for coders to modify code.

When you create a Plugin you hook it into existing vBulletin files, this means you don't need to edit the file directly, making it easier for people to maintain their boards when it comes to updates e.t.c. (Such as if files are overwritten it means people don't have to go back and edit the file each time).

If you are not using a default vBulletin file there is no need to use the Hook and Plugin system. You have control of this file so you don't need Plugins, you put your PHP inside your PHP file. Using the Plugin system is pointless, you have a custom PHP file so you should use it. I'm not sure why you are using a providers_hook.php page as you don't even need that, you just need to put that code into the main PHP file.

lukemax
04-01-2008, 03:41 PM
yea, that makes soo much sense. But I followed that tutorial (https://vborg.vbsupport.ru/showthread.php?t=62164&highlight=vbulletin+powered+page) and made a PROVIDERS template and used the hook in there. Then all that providers.php does is call the template (the only reason I did this cause I wanted the vbulletin stuff (header navbar and footer) to be on the page (like http://www.lvasp.com/forum/providers.php) If you want, take a look at this (its similar to what I'm trying to mimic) http://www.lvasp.com/forum/reviews.php which was created also by a custom template (REVIEWS) and uses that pesky hook system. But when I plug the PHP code into the page which calls the template nothing happens, there is a way to do this without creating a template or using the hook system, but still having all the vbulletin stuff in it to.
If you are not using a default vBulletin file there is no need to use the Hook and Plugin system. You have control of this file so you don't need Plugins, you put your PHP inside your PHP file. Using the Plugin system is pointless, you have a custom PHP file so you should use it. I'm not sure why you are using a providers_hook.php page as you don't even need that, you just need to put that code into the main PHP file.
I dont see how to plug the php code into the template directly, I get an error when I replace the $providers variable in the template (PROVIDERS) with the php code in providers_hook.php. I also tried pasting the code in providers_hook.php directly in the providers.php page into (at line 37 pf screenshot) but is that right?
Thanks and sorry for bugging you with this (again)
(Is my providers.php page ok how it calls the template, its attached too)

Dismounted
04-02-2008, 05:21 AM
Once again, the Hooks/Plugin system, is supposed to be used for adding functionality into vBulletin, not for custom pages. You can put your code inside your custom page. It does not matter if you have followed that tutorial, as it is still PHP.

lukemax
04-02-2008, 06:13 AM
ok, got it (1 more thing still..sorry) But do I need to have my php page call a template. How do add the vbulletin header, footer, and navbar (so the user can login from there) to be in the page too (isnt that what making the PROVIDERS template is for)? Do I even need to deal with making a template and only need a php page (which currently points to the custom template)?
Thanks for the help again.

Dismounted
04-02-2008, 11:45 AM
I think you are getting confused. You DO still call the template, but you DO add your own code into the file.

Boofo
04-02-2008, 12:36 PM
Download my site map hack and look at that. That is a php file hack. A simple one.

lukemax
04-02-2008, 04:22 PM
Dismounted, I tried pasting the code into the php page (screenshot) the same place (beneath the START MAIN SCRIPT comment as I believe boofo did (when I looked at his info.php file), is that what u mean, cause its not working for me. I pasted this PHP code at line 37.

// include MySQL connector function
if (! @include('includes/connection.inc.php')) {
echo 'Sorry, page unavailable';
exit;
}
$conn = dbConnect('query');

// how many rows to show per page
$rowsPerPage = 20;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$result = mysql_query("
SELECT Approve, ID, Name, featured_pic
FROM provider
WHERE Approve = '1'
ORDER BY rand()
LIMIT $offset, $rowsPerPage
");
echo "<table width='70%' cellpading=7 border=1 bordercolor='black' rules='rows' align='center'>";
echo "<tr><th width='120px' class='tcat'>Thumbnail</th>";
echo "<th align='left' class='tcat'>Name</th></tr>";
while ($row = mysql_fetch_array($result))
{
if(empty($row['featured_pic'])) {
$thumb_nail = "<img src='/images/ASP_Images/thumbs/default.jpg' border='0' />";
} else {
$thumb_nail = '<img src="'.$row['featured_pic'].'" alt="'.$row['Name'].'" border="0" />';
}
// Build your formatted results here.
print '<tr>';
print '<th><a href="/provider_page.php?ID=' .$row['ID']. '">'.$thumb_nail.'</a></th>';
print '<th align=\'left\'><a href="/provider_page.php?ID='.$row['ID'].'" class="link">'.$row['Name'].'</a></td>';
print "</tr>";
print "\n";
}
echo "</td></tr></table>";

// how many rows we have in database
$query = "SELECT COUNT(ID) AS numrows FROM provider";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];

// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);

// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';

for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page

if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";

$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = '&nbsp;'; // we're on page one, don't print previous link
$first = '&nbsp;'; // nor the first page link
}

if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";

$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = '&nbsp;'; // we're on the last page, don't print next link
$last = '&nbsp;'; // nor the last page link
}

// print the navigation link
echo "<p style='text-align:center'>".$first . $prev . $nav . $next . $last."</p>";

Dismounted
04-03-2008, 05:29 AM
All output needs to be put into one (or more) variables, and used in the template to display. In vBulletin programming, you will not ever use echo, unless you're doing something really special.

lukemax
04-03-2008, 04:25 PM
ok, thanks...got it.