1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need To Make A Simple Edit To Mybb Plugin, Anyone Want To Help?

Discussion in 'Forum Management' started by cscott5288, Jun 10, 2009.

  1. #1
    Ok, so I got the MyBB link exchange plugin: http://mods.mybboard.net/view/link-exchange-plugin

    and the plugin works great, it's just that it only shows links on the front index of the forum. I want it to show on ALL pages. Can someone edit the plugin for me to do this? I am no php expert unfortunately :(.

    Thanks ahead!

    <?php
    /*
     *        Link Deðiþim Alaný Eklentisi - Link Exchange Center Plugin
     *        Copyright 2008 . All Rights Reserved by LowBattery - www.lowbattery.info
     */
    
    if(!defined("IN_MYBB"))
    {
    	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
    }
    
    $plugins->add_hook("index_start", "lexcange_index_start");
    
    function lexcange_info()
    {	
    	return array(
    		"name" => "Link Exchange Center Plugin",
    		"description" => "Use the plugin display your link exchange codes from forum index.",
    		"website" => "http://www.lowbattery.info",
    		"author" => "LowBattery",
    		"authorsite" => "http://www.lowbattery.info",
    		"version" => "1.0",
    		"compatibility" => "14*",
    	);
    }
    
    function lexcange_install()
    {
        global $settings, $mybb, $db;
    	
    if($db->field_exists("lexcangesis", "users"))
    	{
    	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP lexcangesis"); 
    	}
    	
        $settings_group = array(
            'gid'          => 'NULL',
            'name'         => 'lexcange',
            'title'        => 'Link Exchange Center Plugin',
            'description'  => 'Link Exchange Center Plugin Settings.',
            'disporder'    => '2',
            'isdefault'    => 'no'
        );
        $db->insert_query('settinggroups', $settings_group);
        $gid = $db->insert_id();
    	
        $setting = array(
            'sid'          => 'NULL',
            'name'         => 'linkler',
            'title'        => 'Linkler',
            'description'  => 'Write your link.',
            'optionscode'  => 'textarea',
            'value'        => 'LowBattery - www.lowbattery.info - www.mybbturkiye.com!',
            'disporder'    => '1',
            'gid'          => intval( $gid )
        );
        $db->insert_query( 'settings', $setting );
    
    	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD lexcangesis int NOT NULL default 0");
    
    	rebuild_settings();
    	
    	$insertarray = array(
    		"title" => "lexcange",
    		"template" => "<br /><table class=\"tborder\" border=\"0\" cellpadding=\"6\" cellspacing=\"1\">
    <tr>
    <td class=\"trow1\" valign=\"top\">
    {\$mybb->settings[\'linkler\']}&nbsp;</strong><div class=\"smalltext\"></div>
    </td>
    </tr>
    </table>",
    		"sid" => -1,
    		"dateline" => TIME_NOW
    	);
    	
    	$db->insert_query("templates", $insertarray);
    }
    
    function lexcange_is_installed()
    {
    	global $db;
    	
    	if($db->field_exists("lexcangesis", "users"))
    	{
    		return true;
    	}
    	
    	return false;
    }
    
    function lexcange_activate()
    {
    	global $db;
    	
    	include MYBB_ROOT."/inc/adminfunctions_templates.php";
    	
    	find_replace_templatesets("index", "#".preg_quote("{\$footer}")."#i", "{\$footer}\r\n{\$lexcange}");
    }
    
    function lexcange_deactivate()
    {
    	global $db;
    	
    	include MYBB_ROOT."/inc/adminfunctions_templates.php";
    	
    	find_replace_templatesets("index", "#".preg_quote("\r\n{\$lexcange}")."#i", "", 0);
    }
    
    function lexcange_uninstall()
    {
    	global $db;
    	
    	if($db->field_exists("lexcangesis", "users"))
    	{
    		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP lexcangesis"); 
    	}
    	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='lexcange'");
    	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='linkler'");
    	
    	rebuild_settings();
    	
    	$db->delete_query("templates", "title = 'lexcange'");
    }
    
    function lexcange_index_start()
    {
    	global $db, $mybb, $templates, $lexcange;
    	
    	eval("\$lexcange = \"".$templates->get("lexcange")."\";");
    }
    ?>
    PHP:
     
    cscott5288, Jun 10, 2009 IP
  2. gemini181

    gemini181 Well-Known Member

    Messages:
    2,883
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Hi,

    I can help show you how to "learn by experimenting", are you ready??

    On this line here:

    find_replace_templatesets("index", "#".preg_quote("{\$footer}")."#i", "{\$footer}\r\n{\$lexcange}"); 
    PHP:
    1)
    "index", is the name of the template being changed, and {\$lexcange} is the template variable which displays your links.

    2)
    Let's assume your trying to put the links in the footer of every page...
    ...the next step is easy... :)

    3)
    replace "index", with "footer",
    ...the next step is a bit harder... :p

    4) I would
    a) look in the footer template to pick a spot to place the links
    b) (((This next part isn't hard, you just need to "experiment", !!! you did back up your database, right !!!)))
    c) Here is a simple example...
    <br class="clear" />
    PHP:
    That small code snippet is found in the MyBB footer template, and you want it to look like this

    <br class="clear" />  {$lexcange}
    PHP:
    or if you want extra space, just add a second "break"

    <br class="clear" />  
           <br class="clear" />  {$lexcange}
    PHP:
    ```````
    ```````````

    Here are 4 different ways to do what you are trying to do

    1a) Ask at the site http://www.lowbattery.info
    Oops... :eek:

    1b) Check at the MyBB forum for an English support thread


    Here are the easy do-it-yourself options

    * Find and remove this code in your "index" template
    {$lexcange}
    PHP:
    * Then modify the "footer" template like this

    <br class="clear" />  {$lexcange}
    PHP:
    or

    <br class="clear" />  
           <br class="clear" />  {$lexcange}
    PHP:


    ````````````

    Note:
    The section highlighted in green is an easy solution which should work.

    The plugin can also be modified, but you need to be careful, and deal with all the "escaped stuff" (ie. the parts with backslashes in the PHP code {\$lexcange}, will look different after being inserted into the database.

    *** It's very easy, I was just trying to help teach you about "learning through experimenting." ***

    I hope it works for you.
     
    gemini181, Jun 10, 2009 IP
  3. LowBattery

    LowBattery Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi...

    Im creator of link exchange plugin(and admin of lowbattery.info)

    You can see all pages with link's ;

    1- Login your Admin CP
    2- Edit your Templates
    3- Enter index templates > footer
    paste last line {$lexcange}

    all of them.
     
    LowBattery, Jun 13, 2009 IP
  4. cscott5288

    cscott5288 Active Member

    Messages:
    912
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Hi Lex,

    Where in the footer code exactly?

    Here is my code:
    <div style="overflow:hidden;">
    		<div id="debug"><debugstuff></div>
    	</div>
    	</div>
    			<div class="bottommenu">
    				<div class="float_right" style="margin-top: -4px;">{$lang_select}</div>
    				<div>
    					<span class="smalltext"><a href="{$mybb->settings['contactlink']}">{$lang->bottomlinks_contactus}</a><a href="{$mybb->settings['homeurl']}">{$mybb->settings['homename']}</a><a href="#top">{$lang->bottomlinks_returntop}</a><a href="#content">{$lang->bottomlinks_returncontent}</a><a href="<archive_url>">{$lang->bottomlinks_litemode}</a><a href="{$mybb->settings['bburl']}/misc.php?action=syndication">{$lang->bottomlinks_syndication}</a></span>
    				</div>
    			</div>
    		<hr class="hidden" />
    			<div id="copyright">
    				<a href="http://www.hr-development.net/index.html">Hosting provided by: HR-Development.</a>
    				<!-- You may NOT remove, modify or hinder the visibility of the MyBB copyright at any time.
    				     It must contain the links to the MyBB website and be formatted appropriately.
    
    					 Failure to comply with the above will result in prosecution to the full extent of the law.
    					 This is free software, support us and we'll support you. -->
    				<span>{$lang->powered_by} <a href="http://www.mybboard.net" target="_blank">MyBB{$mybbversion}</a>, &copy; 2002-{$copy_year} <a href="http://www.mybboard.net" target="_blank">MyBB Group</a>.<!-- End copyright -->
    				<!-- You may not remove, modify, or hinder the visibility of the following copyright.
    				     Doing so will void your right to use the theme -->
    				Theme created by <a href="http://community.mybboard.net/user-1830.html"><strong>Justin S.</strong></a>
    				<!-- End theme copyright -->		
    </span>
    			</div>
    		</div> 
    	<!-- The following piece of code allows MyBB to run scheduled tasks. DO NOT REMOVE -->{$task_image}<!-- End task image code -->
    {$auto_dst_detection}
    PHP:
     
    cscott5288, Jun 13, 2009 IP
  5. LowBattery

    LowBattery Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you'r free for use.i think last line...
     
    LowBattery, Jun 13, 2009 IP
  6. cscott5288

    cscott5288 Active Member

    Messages:
    912
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #6
    nope, no effect :(
     
    cscott5288, Jun 13, 2009 IP
  7. gemini181

    gemini181 Well-Known Member

    Messages:
    2,883
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    155
    #7
    If your plugin is activated and this {$lexcange} worked in the index template, then there is no reason why it won't work in the footer.
     
    gemini181, Jun 13, 2009 IP