• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Wanting to add new pages containing PHP from our previous site.

#1
We have just installed XenForo and now looking to know how we add new pages and have the content of our old site in it. This is so we can alter the contents of our current databases which holds other related information to our project. Also we will need to ensure that only members logged in can have access to certain pages and likewise some other pages only accessible to admins or super-admins.

I have found out how to add a new page, but it only allows HTML to be added in. How do I have it so we can use PHP and also know which member type is logged in who is wanting access to the page.

Can anyone give us a little help on where we could start.
 
#3
Thank you, I have had look at the video, and wow this is really starting to excite me a lot. That first stage seems fairly simple so far. What we previously had was a CMS to alter various user entered details. All of this was stored in a different database. This video shows how we can access and display content from the XenForo database. How do I get info from another database shown in a new page ? and allow us to edit this using our already written code, altered slightly so it fits in with the Xen layout.
 

Chris D

XenForo developer
Staff member
#4
Thank you, I have had look at the video, and wow this is really starting to excite me a lot. That first stage seems fairly simple so far. What we previously had was a CMS to alter various user entered details. All of this was stored in a different database. This video shows how we can access and display content from the XenForo database. How do I get info from another database shown in a new page ? and allow us to edit this using our already written code, altered slightly so it fits in with the Xen layout.
It's going to be tricky to say exactly how, but it's definitely a PHP Callback that will help you - probably in the latter stages of that video.

That will enable you to call a PHP file.

This isn't what you want to do, but here's a tutorial someone wrote on making a specific post show up in a page. That uses a PHP Callback:

http://xenforo.com/community/resources/how-to-show-a-post-in-a-page.306/

What you would do is, in that PHP file, load your database, run the queries and return the content.
 
#5
I am starting to get a little lost now. Not sure if I am explaining it right what we are wanting to do.

We have a MySQL database table called 'results' for games that members play on their consoles, once played they enter their results via their pc on to the site and this is updated on the separate databases. We have the PHP that does this, but now sure where I use this. I tried to follow the video in the first reply and thought yes this is what we need, but most of the options selected in the video do not show up in our Xen.
 

Jake Bunce

XenForo moderator
Staff member
#6
Code example of second database connection:

http://xenforo.com/community/resources/run-query-on-user-upgrade-code-example.396/

Basically:

Code:
		$db2 = new Zend_Db_Adapter_Pdo_Mysql(array(
			'host'     => 'localhost',
			'username' => 'dbuser',
			'password' => 'dbpass',
			'dbname'   => 'dbname'
		));

		$records = $db2->fetchAll("
			SELECT *
			FROM tablename
		");
Now $records is an array with all of the records from tablename in the second database.
 
R

ragtek

Guest
#7
I wouldn't use the xenforo pages for this!
You would need to deal with too many unnecesary things...


Create a own controller,route,model,datawriter,etc...
It's IMO the best & cleanest way
 
#10
I wouldn't use the xenforo pages for this!
You would need to deal with too many unnecesary things...


Create a own controller,route,model,datawriter,etc...
It's IMO the best & cleanest way
I have checked again these links and see that it is for pages that need creating from scratch, but our pages are already in use on our old site, and wanting to embed the code from these pages in top the new XenForo pages so the results can be managed within the same platform without having to go to a different site (sub-domain)