Support Forums

how to use a hook?

This is a discussion on how to use a hook? within the Modules / Plugins / Modifications forums, part of the Developer Forums category; I have not used a hook yet...BUT would like to. in the search.tpl file there is this: {modulehook function="tpl_search_footer" options=""} ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 04-10-2010, 11:15 PM   #1
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default how to use a hook?

I have not used a hook yet...BUT would like to.

in the search.tpl file there is this:

{modulehook function="tpl_search_footer" options=""}

What file do I find where I would utilize this function?

-Tom
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!
tlombard is offline   Reply With Quote
Old 04-11-2010, 10:24 AM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

hooks tie into the module system. You can write a moduel and specify the hook taht is used for parts of you module and then anytime a hook is called, in the php or template your mod will place its code/template at that hook point.

Read the developer documentation at the following link.
68 Classifieds Docs - 68 Classifieds
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 04-11-2010, 11:06 AM   #3
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default

ok:

in the search.tpl file there is this:

{modulehook function="tpl_search_footer" options=""}

Lets say I want 'HELLO WORLD' to display in the footer of the search page...and I want the code or the 'Hello World' to be in a hook.

I'm not finding an example of this OR understanding how to make this happen...if I create a module...how does it know to look to that Module...I dont get it?

-Tom
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!
tlombard is offline   Reply With Quote
Old 04-11-2010, 11:48 AM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Look at the code in the writing a module tutorial.

Modules - 68 Classifieds

The example shows you exactly whats needed.


$modules->register('admin_tpl_layout_category', $this, 'admin_links');

When you look at the above line from the example it registers a function from you module to be displayed when a certain hook is called. In the above example 'admin_link" is YOUR function that will get displayed when the hook "admin_tpl_layout_category" is encountered.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 04-11-2010, 01:26 PM   #5
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default

I have previously read that modules pages...it did not help... I'm not creating a new module, I'm simply trying to utilize an existing hook in the default template.

There are hooks scattered through the default template.

These are not third party modules... and I cannot figure out where the hooks file is for the default template, for example. Can someone please break it down to it's basics:

How do I simply display "hello world" using the search page footer hook?
{modulehook function="tpl_search_footer" options=""}

Tom
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!

Last edited by tlombard; 04-11-2010 at 01:55 PM.
tlombard is offline   Reply With Quote
Old 04-11-2010, 02:58 PM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by tlombard
How do I simply display "hello world" using the search page footer hook?
{modulehook function="tpl_search_footer" options=""}

Tom
you create a module. As ive already stated "hooks tie into the module system.".
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 04-11-2010, 03:41 PM   #7
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default

Let me try a different approach.
What am I doing wrong for 'Hello World' to not display in the footer of the search page.

I have switched over to my Evo-Ocean template.

#1
I have created a folder under modules called 'templatetweaks'

#2
I have created a config.php file:
PHP Code:
<?php
    $data
['module']['name'] = "templatetweaks";
    
$data['module']['displayname'] = "Template Tweaks";
    
$data['module']['description'] = "Allows Us to use Template Hooks";
    
$data['module']['version'] = "v1";
    
$data['module']['admin_capable'] = "0";
    
$data['module']['user_capable'] = "1";
?>
#3
I have created a hooks.php file:
PHP Code:
<?php
    
class templatetweaks_events
    
{
        function 
tpl_search_footer()
        {
            echo 
'Hello World';
        }
    }
?>
#4 in the search.tpl there is this hook call.
PHP Code:
{modulehook function="tpl_search_footer" options=""
why is 'Hello World' not displayed at the bottom of the search page?
I don't get how this hook is called.

-Tom
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!
tlombard is offline   Reply With Quote
Old 04-11-2010, 04:12 PM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by tlombard
Let me try a different approach.
What am I doing wrong for 'Hello World' to not display in the footer of the search page.

I have switched over to my Evo-Ocean template.

#1
I have created a folder under modules called 'templatetweaks'

#2
I have created a config.php file:
PHP Code:
<?php
    $data
['module']['name'] = "templatetweaks";
    
$data['module']['displayname'] = "Template Tweaks";
    
$data['module']['description'] = "Allows Us to use Template Hooks";
    
$data['module']['version'] = "v1";
    
$data['module']['admin_capable'] = "0";
    
$data['module']['user_capable'] = "1";
?>
#3
I have created a hooks.php file:
PHP Code:
<?php
    
class templatetweaks_events
    
{
        function 
tpl_search_footer()
        {
            echo 
'Hello World';
        }
    }
?>
#4 in the search.tpl there is this hook call.
PHP Code:
{modulehook function="tpl_search_footer" options=""
why is 'Hello World' not displayed at the bottom of the search page?
I don't get how this hook is called.

-Tom
Because you didnt follow the directions when you created your module. As I also stated above you need to "register" your function and tie it to a hook.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 04-11-2010, 04:24 PM   #9
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default

my bad...I pasted the first WRONG hook.php content, not what I actually was using.

here is my hook.php file:

PHP Code:
<?php
    
class templatetweaks_events
    
{
        function  
templatetweaks_events(&$modules)
        {
            
$modules->register('tpl_search_footer'$this'search_footer');
        }

        function 
search_footer()
        {
            echo 
"Hello World";
        }
    }
?>
here is the search page hook call:
PHP Code:
{modulehook function="tpl_search_footer" options=""
now what am I missing?

Lhotch, you always this charming?
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!
tlombard is offline   Reply With Quote
Old 04-11-2010, 04:48 PM   #10
Customer
 
tlombard's Avatar
 
Join Date: Oct 2009
Location: Parker, CO
Posts: 37
Rep Power: 8
tlombard is on a distinguished road
Default

Gotta 'Activate' the module...Administration / Settings / Modules
__________________
-Tom

GunListUSA.com
Gun List USA is Better...
No Auctions, Just FREE Ads!!!
tlombard is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
searchlisting_joins hook request cheesegrits Technical Support 2 02-10-2008 09:16 PM


All times are GMT -4. The time now is 07:00 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0