Link to Us Page

A perfect place for code snippets to small to be a MOD or a library.
Or for examples on how to use our libraries.
Post Reply
User avatar
tumba25
Supporter
Supporter
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Link to Us Page

Post by tumba25 »

This post was originally posted by Kenny at 6 String MODs, I have made some minor adjustments and we in the team will try to fix any bugs in the included codes.

Posted by request from [url=http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=282264]Fridge[/url] in [url=http://www.phpbb.com/community/viewtopic.php?p=6543995#p6543995]this post[/url].
Basically this snippet creates a pop-up page. The contents of the pop-up is a pre-generated HTML link to your forum, which people can use to link to your board. The link automatically opens in a new window, using javascript to keep it XHTML valid :) The pop-up itself is based on the private message pop-up code :geek:

Create file: styles/prosilver/template/link_body.html

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}" xml:lang="{S_USER_LANG}">
<head>

<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="{S_USER_LANG}" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
<title>{SITENAME} &bull; <!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

<script type="text/javascript">
// <![CDATA[

   var onload_functions = new Array();
   var onunload_functions = new Array();

   /**
   * New function for handling multiple calls to window.onload and window.unload by pentapenguin
   */
   window.onload = function()
   {
      for (var i = 0; i < onload_functions.length; i++)
      {
         eval(onload_functions[i]);
      }
   }

   window.onunload = function()
   {
      for (var i = 0; i < onunload_functions.length; i++)
      {
         eval(onunload_functions[i]);
      }
   }

// ]]>
</script>
<script type="text/javascript" src="{T_TEMPLATE_PATH}/styleswitcher.js"></script>

<link href="{T_STYLESHEET_LINK}" rel="stylesheet" type="text/css" media="screen, projection" />

<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->
   <link href="{T_THEME_PATH}/bidi.css" rel="stylesheet" type="text/css" media="screen, projection" />
<!-- ENDIF -->

<!-- DEFINE $POPUP = 1 -->

</head>

<body id="phpbb" class="{S_CONTENT_DIRECTION}">

<div id="simple-wrap">
   <a id="top" name="top" accesskey="t"></a>
   <div id="page-body">

<div class="panel">
   <div class="inner"><span class="corners-top"><span></span></span>
   <div class="content">

      <h3>{L_LINK_US}</h3>
      <p>{LINK_US_TXT}</p>
      <input type="text" tabindex="1" size="90" value="{U_LINK_US}" class="inputbox autowidth" /><br /><br />

   </div>
   <span class="corners-bottom"><span></span></span></div>
</div>

   </div>
<!--
   We request you retain the full copyright notice below including the link to www.phpbb.com.
   This not only gives respect to the large amount of time given freely by the developers
   but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
   the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
   "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
   forums may be affected.

   The phpBB Group : 2006
//-->

</div>

</body>
</html>


Create file: link.php

Code: Select all

<?php
/**
*
* @package Link to Us page
* @version $Id: link.php,v 0001 22:34 28/04/2008 kenny Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';  // Remember and change this to refelct your site
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include(
$phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Output page
page_header($user->lang['LINK_US']);

// Set the template for the page
$template->set_filenames(array(
    'body' => 'link_body.html'
));

// Assign specific vars
$template->assign_vars(array(
    'LINK_US_TXT'    => sprintf($user->lang['LINK_US_TXT'], $config['sitename']),
    'U_LINK_US'        => htmlentities('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '">' . $config['sitename'] . '</a>'),
));

page_footer();

?>

includes/functions.php
Find:

Code: Select all

        'L_INDEX'            => $user->lang['FORUM_INDEX'],&nbsp;&nbsp;&nbsp;&nbsp

AFTER, ADD:

Code: Select all

        'U_LINK_US'             => append_sid("{$phpbb_root_path}link.$phpEx"),&nbsp;&nbsp;&nbsp;&nbsp

Change the append_sid value to reflect where on your server the linp.php file is. The above code assumes it's in your forums root folder.

language/en/common.php

FIND:

Code: Select all

    'LEGEND'                            => 'Legend',&nbsp;&nbsp;&nbsp;&nbsp

AFTER, ADD:

Code: Select all

    'LINK_US'                            => 'Link to us',
    'LINK_US_TXT'                        => 'Please feel free to link to <strong>%s</strong>. Use the following HTML:',&nbsp;&nbsp;&nbsp;&nbsp


The code below is placed wherever you want the "Link to Us" text to display. The can be in your header, footer, index. It has to be in a phpBB template file though or it won't work. You could easily incorporate it into a custom phpBB page :)

Code: Select all

<div style="text-align: center;" id="link">
<a href="{U_LINK_US}" onclick="popup(this.href, 588, 218, '_linktous'); return false;" style="font-size: 13px;">{L_LINK_US}</a><br /></div>

The 2 numbers in popup code are the width & height respectively. Adjust these to your needs.
That should be it. I'll update this topic if there are any other changes 8-)
Last edited by tumba25 on 13 Jan 2015, 00:00, edited 2 times in total.
Reason: Edited code
neuropass
Member
Member
Posts: 66
Joined: 12 Apr 2010, 17:07

Re: Link to Us Page

Post by neuropass »

Interesting , is there any demo for it? I would like to see it to have an idea.. I guess even a screenshot would make it. :?
User avatar
tumba25
Supporter
Supporter
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: Link to Us Page

Post by tumba25 »

Not at the moment, you'll get a popup page with text boxes like on [url=http://phpbbmodders.net/]this[/url] page.
steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk
Contact:

Re: Link to Us Page

Post by steve »

Cute i like it!! :)

But in the link.php should'nt,

This:

Code: Select all

page_header("Home");

Be:

Code: Select all

page_header($user->lang['LINK_US']);


This also may be invalid html depending where its placed:

Code: Select all

<div style="text-align: center;" id="link">
<a href="{U_LINK_US}" onclick="popup(this.href, 588, 218, '_linktous'); return false;" style="font-size: 13px;">{L_LINK_US}</a></div>
<br />

could be:

Code: Select all

<div style="text-align: center;" id="link">
<a href="{U_LINK_US}" onclick="popup(this.href, 588, 218, '_linktous'); return false;" style="font-size: 13px;">{L_LINK_US}</a><br /></div>


:ninja:
Steve ©
User avatar
RMcGirr83
Supporter
Supporter
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Re: Link to Us Page

Post by RMcGirr83 »

Quite right Steve, thanks. :beer:

First post updated.
steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk
Contact:

Re: Link to Us Page

Post by steve »

Been looking for something like this wasnt quite there so had a play, and here's my version :)

link.php code:

Code: Select all

<?php
/**
*
* @package Link to Us page
* @version $Id: link.php,v 0001 22:34 28/04/2008 kenny Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';  // Remember and change this to refelct your site
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Output page
page_header($user->lang['LINK_US']);

// Set the template for the page
    $template->set_filenames(array(
        'body' => 'link_body.html'
    ));

// Assign specific vars
    $template->assign_vars(array(
        'LINK_US_TXT'          => sprintf($user->lang['LINK_US_TXT'], $config['sitename']),
      'THANKS_TEXT'          => sprintf($user->lang['THANKS_TEXT'], $config['sitename']),
        'U_LINK_US'              => htmlentities('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . $config['sitename'] . '</a>'),
        'U_LINK_US_D'           => ('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . $config['sitename'] . '</a>'),       
      'U_LINK_US_SMALL'      => htmlentities('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . '<img src="' . generate_board_url() . '/images/banner.png" width="50%" height="50%" alt="' .$config['sitename'] . '" />' . '</a>'),
        'U_LINK_US_SMALL_D'      => ('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . '<img src="' . generate_board_url() . '/images/banner.png" width="50%" height="50%" alt="' .$config['sitename'] . '" />' . '</a>'),
        'U_LINK_US_BANNER'     => htmlentities('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . '<img src="' . generate_board_url() . '/images/banner.png" alt="' .$config['sitename'] . '" />' . '</a>'),
      'U_LINK_US_BANNER_D'     => ('<a href="' . generate_board_url() . '/" title="' . $config['site_desc'] . '"  onclick="window.open(this.href); return false;">' . '<img src="' . generate_board_url() . '/images/banner.png" alt="' .$config['sitename'] . '" />' . '</a>'),
        'U_LINK_US_BB_TEXT'     => htmlentities('[url]' . generate_board_url() . '/' . '[/url]'),
        'U_LINK_US_BB_BANNER'     => htmlentities('[url=' . generate_board_url() . '/' . '][img]' . generate_board_url() . '/' . '/images/banner.png' . '[/img][/url]'),                 
   ));

page_footer();

?>

language/en/common.php changed code:

Code: Select all

   'COPY_TEXT'               => 'Select then Right Click and Copy Code',
    'LINK_US'                   => 'Link to us',
    'LINK_US_TXT'               => 'Please feel free to Create a  link to our Forum <em><strong>" %s "</strong></em><br />You can do so by using the following codes:',
   'HTML'                  => 'HTML/Text Link:',
   'HTML_LINK'               => 'HTML Links for Website’s.',
   'BBCODE_LINK'            => 'BBcodes for Forum Post’s.',
   'BANNER_S'               => 'Small Logo Link:',
   'BANNER'               => 'Logo Link:',
   'BBCODE_TEXT'            => 'BBcode Text Link:',
   'BBCODE_BANNER'            => 'BBcode Banner Link:',
   'THANKS_TEXT'            => 'Thankyou, <em><strong>%s</strong></em>',

prosilver/template/link_body.html code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}" xml:lang="{S_USER_LANG}">
<head>

<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="{S_USER_LANG}" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
<title>{SITENAME} &bull; <!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

<script type="text/javascript">
// <![CDATA[

   var onload_functions = new Array();
   var onunload_functions = new Array();

   /**
   * New function for handling multiple calls to window.onload and window.unload by pentapenguin
   */
   window.onload = function()
   {
      for (var i = 0; i < onload_functions.length; i++)
      {
         eval(onload_functions[i]);
      }
   }

   window.onunload = function()
   {
      for (var i = 0; i < onunload_functions.length; i++)
      {
         eval(onunload_functions[i]);
      }
   }

// ]]>
</script>
<script type="text/javascript" src="{T_TEMPLATE_PATH}/styleswitcher.js"></script>

<link href="{T_STYLESHEET_LINK}" rel="stylesheet" type="text/css" media="screen, projection" />

<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->
   <link href="{T_THEME_PATH}/bidi.css" rel="stylesheet" type="text/css" media="screen, projection" />
<!-- ENDIF -->

<!-- DEFINE $POPUP = 1 -->

</head>

<body id="phpbb" class="{S_CONTENT_DIRECTION}">

<div id="simple-wrap">

     <div class="headerbar">
      <div class="inner"><span class="corners-top"><span></span></span>   
      
      <a id="top" name="top" accesskey="t"></a>
      <div style="text-align: center;">{SITE_LOGO_IMG}</div>
      
      <span class="corners-bottom"><span></span></span></div>
   </div>
      
   <div id="page-body">      
   
   <div class="panel">
      <div class="inner"><span class="corners-top"><span></span></span>
      <div class="content">

       <h3>{L_LINK_US}</h3>
      <p>{LINK_US_TXT}</p>
      
   <fieldset class="fields1">    
      <dl>
            <dd><strong><em>{L_HTML_LINK}</em></strong></dd>
         <dt><label>{L_HTML}</label></dt>
            <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US}" title="{L_COPY_TEXT}" /></dd>
         <dt><label>{L_BANNER}</label></dt>
            <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BANNER}" title="{L_COPY_TEXT}" /></dd>      
         <dt><label>{L_BANNER_S}</label></dt>
            <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_SMALL}" title="{L_COPY_TEXT}" /></dd>                  
            <dd>&nbsp;</dd>               
            <dd><strong><em>{L_BBCODE_LINK}</em></strong></dd>   
         <dt><label>{L_BBCODE_TEXT}</label></dt>
            <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BB_TEXT}" title="{L_COPY_TEXT}" /></dd>         
         <dt><label>{L_BBCODE_BANNER}</label></dt>
            <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BB_BANNER}" title="{L_COPY_TEXT}" /></dd>               
      </dl>
   </fieldset>   
<hr class="dashed" />
<div style="float: right;font-size: 13px;">{THANKS_TEXT}</div>
      </div>
      <span class="corners-bottom"><span></span></span></div>
   </div>

</div>
<!--
   We request you retain the full copyright notice below including the link to www.phpbb.com.
   This not only gives respect to the large amount of time given freely by the developers
   but also helps build interest, traffic and use of phpBB3. If you (honestly) cannot retain
   the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
   "phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
   forums may be affected.

   The phpBB Group : 2006
//-->

   <div class="copyright"><br />Powered by <a href="http://www.phpbb.com/">phpBB</a> &copy; 2000, 2002, 2005, 2007 phpBB Group
      <!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
   </div>
   
</div>

</body>
</html>


Link to placed in prosilver/template/overall_hear.html:

Code: Select all

            <li class="icon-subscribe" id="link"><a href="{U_LINK_US}" onclick="popup(this.href, 588, 408, '_linktous'); return false;">{L_LINK_US}</a></li>


Before or after this:

Code: Select all

<li class="icon-faq"><a href="{U_FAQ}" title="{L_FAQ_EXPLAIN}">{L_FAQ}</a></li>


:beer: :rootbeer:

Screenshot if need be :)

prosilver.PNG
Steve ©
User avatar
tumba25
Supporter
Supporter
Posts: 1049
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: Link to Us Page

Post by tumba25 »

Thanks.
User avatar
Fluffybunny
New member
New member
Posts: 9
Joined: 15 Mar 2011, 23:02

Re: Link to Us Page

Post by Fluffybunny »

Nice code but I prefer to use my 'Link to Us' page as a new page and they click the new page and it comes up instead of the popup as not a fan of popup's.

Though does the same thing. ;P
steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk
Contact:

Link to Us Page

Post by steve »

easilly solved :)

html for link:

Code: Select all

            <li class="icon-subscribe" id="link"><a href="{U_LINK_US}">{L_LINK_US}</a></li>

html for link prosilver/template/link_body.html:

Code: Select all

<!-- INCLUDE overall_header.html -->

       <div class="panel">
          <div class="inner"><span class="corners-top"><span></span></span>
          <div class="content">

           <h3>{L_LINK_US}</h3>
          <p>{LINK_US_TXT}</p>
         
       <fieldset class="fields1">   
          <dl>
                <dd><strong><em>{L_HTML_LINK}</em></strong></dd>
             <dt><label>{L_HTML}</label></dt>
                <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US}" title="{L_COPY_TEXT}" /></dd>
             <dt><label>{L_BANNER}</label></dt>
                <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BANNER}" title="{L_COPY_TEXT}" /></dd>     
             <dt><label>{L_BANNER_S}</label></dt>
                <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_SMALL}" title="{L_COPY_TEXT}" /></dd>                 
                <dd>&nbsp;</dd>               
                <dd><strong><em>{L_BBCODE_LINK}</em></strong></dd>   
             <dt><label>{L_BBCODE_TEXT}</label></dt>
                <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BB_TEXT}" title="{L_COPY_TEXT}" /></dd>         
             <dt><label>{L_BBCODE_BANNER}</label></dt>
                <dd><input type="text" size="50" class="inputbox autowidth" onclick="this.focus();this.select();" value="{U_LINK_US_BB_BANNER}" title="{L_COPY_TEXT}" /></dd>               
          </dl>
       </fieldset>   
    <hr class="dashed" />
    <div style="float: right;font-size: 13px;">{THANKS_TEXT}</div>
          </div>
          <span class="corners-bottom"><span></span></span></div>
       </div>

<!-- INCLUDE overall_footer.html -->
Steve ©
Post Reply