Full Site Integration

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
adk_tj
Registered User
Posts: 47
Joined: Wed Aug 24, 2005 1:20 pm

Re: Full Site Integration

Post by adk_tj »

Another item:

I'm trying to produce an array like this:

User Name:ADK_TJ
First Name Last Name
Phone:
Email: email @ mysite.com

I pulled your code from page 79 (which you answered for me the first time apparently!) but that only produces two entries: the username and first name. How do I get it to show more than those two entries - the pf_first_name, pf_last_name, and pf_phone?

Code: Select all

$group_id = array(13); 
    $user_id_ary = array();
    $user_id_ary = group_memberships($group_id);

    include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
    $cp = new custom_profile();

    $user_ids = array();
    foreach($user_id_ary as $user_id)
    {
        $user_ids[] = $user_id['user_id'];
    }

    // Grab all profile fields from users in id cache for later use - similar to the poster cache
    $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_ids);

echo '<table border="1"><tr><td>Username</td><td>First Name</td></tr>';
foreach($user_id_ary as $user_id)
{
    echo '<tr><td>' . $user_id['username'] . '</td><td>' . $profile_fields_cache[$user_id['user_id']]
['first_name']['value']['last_name']['value'] . '</td></tr>';   <------WON'T WORK AS WRITTEN
}
echo '</table>';

    unset($profile_fields_cache); 

If I pull the ['last_name']['value'] out, I get the Username First Name back. With it I get
Fatal error: Cannot use string offset as an array in /public_html/test.php on line 25
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10484
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Full Site Integration

Post by Noxwizard »

Superkylling wrote:Hello. I followed the first 2 pages to make a login system, but when i Login im being directed to forums, but i want it to just login and refresh the page and it would be saying You are Currently logged in as 'username' and would state a logout and inbox screen:) Is it possible? Im very noob at Php/html but kind of know things :/ :P

Thanks alot in advance.
http://www.phpbb.com/community/viewtopi ... 5#p5465545
To bypass the login message, follow the last comment in this post: http://www.phpbb.com/community/viewtopi ... #p11124755


Could it be an issues with WAMP or XAMPP.

I have tried both programs but still having the same issue, the only other thing I can think of is installing everything individualy.
Did you make sure it wasn't saved with a BOM? (Notepad++: Format --> Encode in UTF-8 Without BOM)


Vikestart wrote:EDIT 3:
It seems like the news script is ignoring linebreaks.... Is it possible to fix?

EDIT 4:
And is it possible to display which forum the topic is pulled from because I have several 'divisions' and I want people to be able to easier know what kind of news that they're looking at.
You really need to start providing links to the snippets or actually post the code, so I don't have to track it down and hope it's the right one that you're using. If it's the same news script from 3 pages back, I don't know how you would have line breaks since topic titles can't have them anyways.
In general, this would work:

Code: Select all

$text = bbcode_nl2br($text);
As for the second, you'll have to join against the forums table to pull the name out.

Code: Select all

INNER JOIN ' . FORUMS_TABLE . ' f ON (t.forum_id = f.forum_id)
and add f.forum_name to the SELECT.


adk_tj wrote:Is this doable?
Yes. For updating profile fields, you just update the profile fields data table.

Code: Select all

$profile_fields_cache[$user_id['user_id']]['first_name']['value']['last_name']['value']
That's not how it works, which is why it gives an error. It should be:

Code: Select all

$profile_fields_cache[$user_id['user_id']]['first_name']['value'] . ' ' . $profile_fields_cache[$user_id['user_id']]['last_name']['value'] 
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
Superkylling
Registered User
Posts: 2
Joined: Sun Nov 01, 2009 10:42 pm

Re: Full Site Integration

Post by Superkylling »

Noxwizard wrote:
Superkylling wrote:Hello. I followed the first 2 pages to make a login system, but when i Login im being directed to forums, but i want it to just login and refresh the page and it would be saying You are Currently logged in as 'username' and would state a logout and inbox screen:) Is it possible? Im very noob at Php/html but kind of know things :/ :P

Thanks alot in advance.
http://www.phpbb.com/community/viewtopi ... 5#p5465545
To bypass the login message, follow the last comment in this post: http://www.phpbb.com/community/viewtopi ... #p11124755



Hello again, where do i put the first link you sent me? in the html? And what do I change? :)
DrP
Registered User
Posts: 4
Joined: Sun Mar 06, 2005 5:09 pm
Location: ON
Contact:

Re: Full Site Integration

Post by DrP »

Hello there,

I have gone through a good 20 pages of this topic trying to find usable code...but I simply cannot sit and sift through all 94 pages, so hopefully Noxwizard or someone else can give me a hand.

I'm trying to display the latest topics from a particular forum on a non-phpBB page. Yes, I do realize there are many different code sets for accomplishing this in this topic, but none seem to work exactly for what I would like them to do - and I'll try my best to explain what it is I'm looking for.

I'm looking to create a function in a separate file (which I can then include), that when called, returns a string of HTML formatted text to display the 5 latest topics from forum ID 11. Included should be the title of the Topic (links to the topic), the date/time the topic was started, the user who posted the topic (links to user's profile), followed by the text of the post itself (bbcode parsed and displayed correctly), and finally display how many comments/replies the topic has received (links to the topic), but not actually display the comments themselves.

Assuming all this works correctly, I would be able to assign a the returned value of the function to a template variable, and access it through the template - as the example given below:

Code: Select all

$template->assign_vars(array(
		'U_FORUM_INCLUDE'   => forum_include_posts(),
));
Thanks in advance =)
~DrP
User avatar
Vikestart
Registered User
Posts: 98
Joined: Sat Apr 25, 2009 5:14 pm
Name: Aleksander
Contact:

Re: Full Site Integration

Post by Vikestart »

EDIT: Ooops... Figured it out. Litte, but tricky mistake by me...

Thanks again, Noxwizard. Sorry for asking so much.
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10484
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Full Site Integration

Post by Noxwizard »

Superkylling wrote:
Noxwizard wrote:http://www.phpbb.com/community/viewtopi ... 5#p5465545
To bypass the login message, follow the last comment in this post: http://www.phpbb.com/community/viewtopi ... #p11124755
Hello again, where do i put the first link you sent me? in the html? And what do I change? :)
No, you cannot run PHP code in an HTML document. The page will have to have a .php extension. The first 8 or so lines need to go at the very top of the page. The rest go wherever you want to login box to appear. Like I said in the comment that I directed you to, replace the meta_refresh() and trigger_error() lines with that code.


DrP wrote:Hello there,

I have gone through a good 20 pages of this topic trying to find usable code...but I simply cannot sit and sift through all 94 pages, so hopefully Noxwizard or someone else can give me a hand.

I'm trying to display the latest topics from a particular forum on a non-phpBB page. Yes, I do realize there are many different code sets for accomplishing this in this topic, but none seem to work exactly for what I would like them to do - and I'll try my best to explain what it is I'm looking for.

I'm looking to create a function in a separate file (which I can then include), that when called, returns a string of HTML formatted text to display the 5 latest topics from forum ID 11. Included should be the title of the Topic (links to the topic), the date/time the topic was started, the user who posted the topic (links to user's profile), followed by the text of the post itself (bbcode parsed and displayed correctly), and finally display how many comments/replies the topic has received (links to the topic), but not actually display the comments themselves.

Assuming all this works correctly, I would be able to assign a the returned value of the function to a template variable, and access it through the template - as the example given below:

Code: Select all

$template->assign_vars(array(
		'U_FORUM_INCLUDE'   => forum_include_posts(),
));
Thanks in advance =)
You will not find anything in the next 70 pages either that is exactly what you want. You will need to adapt any of the given examples. Instead of using echo's, just append it to a string and return that string at the end.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
DrP
Registered User
Posts: 4
Joined: Sun Mar 06, 2005 5:09 pm
Location: ON
Contact:

Re: Full Site Integration

Post by DrP »

Noxwizard wrote:You will not find anything in the next 70 pages either that is exactly what you want. You will need to adapt any of the given examples. Instead of using echo's, just append it to a string and return that string at the end.
Okay so I've already done this and created the file "/includes/announcement_posts.php" with the function. Changed the echo's to .= my return string and assigned the template value in the home php file.... the only problem is I get this error: Fatal error: Call to a member function acl_getf() on a non-object in /includes/announcement_posts.php on line 16
Line 16:

Code: Select all

$can_read_forum = $auth->acl_getf('f_read');
And if I try to remove the bit of code that checks to see if the user has access to see the forum, I get this error instead: Fatal error: Call to a member function sql_query_limit() on a non-object in /includes/announcement_posts.php on line 44
Line 44:

Code: Select all

$result = $db->sql_query_limit($sql, $num_posts);
It would seem $auth and $db aren't being set properly, but I'm not versed enough in php/sql to fully understand it.
~DrP
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10484
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Full Site Integration

Post by Noxwizard »

Since $auth and $db were created outside of the function, you need to extend their scope with the "global" keyword.

Code: Select all

function whatever()
{
     global $auth, $db, $user;
...
}
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
radp
Registered User
Posts: 2
Joined: Tue Nov 10, 2009 2:04 am

Re: Full Site Integration

Post by radp »

Hello and thank you very much Noxwizard for your help.

I have been trying for a couple of days to integrate the my site (WIP) with my forum. However, every method I try ends up with some errors.

First of all, the current script I'm trying to use is the one Noxwizard wrote.

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = '../forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
     
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    if($user->data['is_registered'])
    {
        echo "Welcome " . $user->data['username']; //User is already logged in
    }
    else if(isset($_POST['login']))
    {
        $username = request_var('username', '', true);
        $password = request_var('password', '', true);
        $autologin = (!empty($_POST['autologin'])) ? true : false;

        $result = $auth->login($username, $password, $autologin);

        if ($result['status'] == LOGIN_SUCCESS)
        {
            //User was successfully logged into phpBB
            $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");

            // append/replace SID
            $redirect = reapply_sid($redirect);

            meta_refresh(0, $redirect);
            trigger_error('You have been logged in');
        }
        else
        {
            echo 'Bad Login ' . $username; //User's login failed
        }
    }
    else
    {
        echo '
            Please log in:<br />
            <form method="POST" action="_SELF">
            <p>Username: <input type="text" name="username" size="40"><br />
            Password: <input type="password" name="password" size="40"><br />
            Remember Me?: <input type="checkbox" name="autologin"><br />
            <input type="submit" value="Submit" name="login"></p>
            </form>';
    }
    ?>
And when I run the page (Test.php) here is the output
http://localhost/release/forum/test.php wrote: [phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /test.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /test.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1006: Cannot modify header information - headers already sent by (output started at /test.php:1)
Please log in:

Username: [input box]
Password: [input box]
Remember Me?: [x]
And when I try to login, I recieve an error I saw elsewhere in the thread, however I cannot find it again! :oops:
http://localhost/release/forum/_SELF wrote: Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
11/10/09 18:06:55
Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0
Anyhelp would be great! Thank you very much!
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10484
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Full Site Integration

Post by Noxwizard »

Delete any spaces/blank lines before the <?php. For the second, try changing the action from "_SELF" to "", or to the name of the file.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
radp
Registered User
Posts: 2
Joined: Tue Nov 10, 2009 2:04 am

Re: Full Site Integration

Post by radp »

Thank you very much! That corrected both problems! :D
Russelltoo
Registered User
Posts: 3
Joined: Fri Nov 13, 2009 11:56 am

Re: Full Site Integration

Post by Russelltoo »

I've looked at this thread a couple of times and used some of the suggestions to build a menu system for my site that changes depending on the login and groups status of the user and I'm grateful for that help.

This seems to work nicely until I try and combine it with the forum page. I had previously added the site menus to the forum by including the page header in the overall_header.html file.

Code: Select all

<!-- PHP -->
include $_SERVER['DOCUMENT_ROOT']."/pages/menu/combsheader.php";
<!-- ENDPHP -->
Now my new header also tries to access phpbb data and I get a deregister globals error due to calling common.php twice. I've tried removing the lines that are obviously duplicated (marked between lines of asterixes) and then get error messages about calling functions on non objects. Here is the code for my header and menu.

Code: Select all

<?php 
$today = date('l');
$today = "new".$today.".jpg";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Combs Sailing Club Online</title>
<link href="/stylesheets/combsnew.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper"> 
  <div class="combsheader" style="background-image:url(/stylesheets/Header_Graphics/<?php	
	echo $today;?>)"> 
	<img src="/stylesheets/Header_Graphics/name.gif" alt="Combs Sailing Club Online Graphic"> 
	  </div>
  <div class="menu"> 
    <div id="nav"> 
      <ul class="level1">
        <li><a href="/pages/newhome.php">Home</a></li>
        <li class="submenu"><a href="#">About&nbsp;us</a> 
          <ul class="level2">
            <li><a href="/pages/aboutus/gp.php">GP Committee</a></li>
            <li><a href="/pages/aboutus/sailin.php">Sailing Committee</a></li>
            <li><a href="/pages/aboutus/const.php">Constitution</a></li>
            <li><a href="/pages/aboutus/inst.php">Sailing Instructions</a></li>
            <li><a href="/pages/aboutus/location.php">Location</a></li>
            <li><a href="/pages/aboutus/memb.php">Club Membership</a></li>
          </ul>
        </li>
		<li class='submenu'><a href='#'>Members</a> 
 <?php       
		
	$group_ids = array(15,);
****************************
$curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT']."/phpBB3/";
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
*****************************
$user_ary = array();
$sql = 'SELECT user_id
        FROM ' . USER_GROUP_TABLE . '
        WHERE ' . $db->sql_in_set('group_id', $group_ids);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
    $user_ary[$row['user_id']] = $row['user_id'];
}
$db->sql_freeresult($result);
if ($user->data['user_id'] == ANONYMOUS)//not logged in
{echo"
          <ul class='level2'>
            <li><a href='/pages/members/member.php'>Log In</a> 
            </li>
          </ul>"
       ;}

else	{
//CHECK TO SEE IF THE USER IS authorised 
if (!in_array($user->data['user_id'], $user_ary))
// not authorised
{{echo"
          <ul class='level2'>
            <li><a href='/pages/members/member.php'>Contact Webmaster</a> 
              
            </li>
          </ul>"
       ;}}
	
else
{echo "
          <ul class='level2'>
            <li class='submenu'><a href='#'>Pages</a> 
              <ul class='level3'>
                <li><a href='/pages/members/clubboats.php'>Club Boats</a></li>
                <li><a href='/pages/members/boatpark.php'>Boat Park</a></li>
                <li><a href='/pages/members/equipment.php'>Equipment</a></li>
                <li><a href='/pages/members/trophies.php'>Trophies</a></li>
				<li><a href='/pages/members/keys.php'>Keys</a></li>
              </ul>
            </li>
          </ul>
       
";}}
?>
                     
	</li>
 
	  <li class="submenu"><a href="/pages/news/news.php">News</a> 
          <ul class="level2">
            <li><a href="/pages/news/weather.php">Weather</a></li>
			<li><a href="/calendar/index.php">Calendar</a></li>
            <li><a href="/pages/news/events.php">Events</a></li>
			<li><a href="/pages/results/newresults.php">Results</a></li>
            <li><a href="/phpBB3/index.php">Forum</a></li>
          </ul>
        </li>
        <li><a href="/pages/contact/newfeedback.php">Contact</a></li>
      </ul>
      <div class="combssearch"> 
        <form style="margin-bottom:0;"  id="searchbox_000355969819809325700:p7uxqqj20di" action="/pages/searchresults.shtml">
          <input type="hidden" name="cx" value="000355969819809325700:p7uxqqj20di" >
          <input name="q" type="text" value="Site Search" size="14" class ="googform" >
          <input type="submit" name="sa" value="Go" class ="googform">
          <input type="hidden" name="cof" value="FORID:11" >
        </form>
        <script type="text/javascript" src="http://google.com/coop/cse/brand?form=searchbox_000355969819809325700%3Ap7uxqqj20di"></script>
      </div>
    </div>
  </div>
  <div class="content">
I'd be grateful for any pointers about how I can get these to work together.

Thanks
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10484
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Full Site Integration

Post by Noxwizard »

Put a check for IN_PHPBB around the session code, so it only includes those files if they haven't already been included.

Code: Select all

if(!defined('IN_PHPBB'))
{
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ?  PHPBB_ROOT_PATH : $_SERVER['DOCUMENT_ROOT']."/phpBB3/";
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
} 
That block really needs to be the first thing on the page, else you can get header() errors.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
Russelltoo
Registered User
Posts: 3
Joined: Fri Nov 13, 2009 11:56 am

Re: Full Site Integration

Post by Russelltoo »

Hi

Thanks for that - I've done that and I've also included some other bits like page headers so they are only included once in the final page. I still haven't been able to sort out the other part of the problem which is that when I've done this I get error messages like

Fatal error: Call to a member function sql_in_set() on a non-object in ..........on line 86.

The relevant lines (84 to 86) are

$sql = 'SELECT user_id
FROM ' . USER_GROUP_TABLE . '
WHERE ' . $db->sql_in_set('group_id', $group_ids);

If I delete these lines I get a similar error on a function further down the page.

I suspect there is something obvious staring me in the face but I can't see it. index.php is calling all the phpbb functions, then overall header is calling my header file which isn't working correctly, then it should call the rest of the phpbb page.

I'd be grateful for any help.

Russell
Russelltoo
Registered User
Posts: 3
Joined: Fri Nov 13, 2009 11:56 am

Re: Full Site Integration

Post by Russelltoo »

I've got this sorted now.

I added some code to the index.php page right at the start to set some control variables which I copuld then check in my header file.

Russell
Locked

Return to “[3.0.x] MOD Writers Discussion”