Jump to content

PHP in Pages


AmethystBlack

Recommended Posts

hhhhh so i've been using IPB for years with a separate CMS built in php. recently i made the decision to upgrade to 4.x and get Pages so I could pull the two halves of my site together. however, I am struggling to adjust to invision's Pages app and I feel like I've already tossed one too many dumb questions at the official support. I also haven't had much luck searching, because as it turns out "Pages" and "IP.Content" are sort of generic terms ;;

what I'm trying to do, for starters, is create basically a feed of topics from our news forum. 
so I first looked at the preset blocks pages includes... but they're not quite what I'm looking for. the Topic Feed block sounded promising, but it only displays the topic title and info, whereas I want to display the first post of each topic. I looked to Post Feed in turn, but this displays every post from the forum or topic, rather than just the first post that actually contains the announcements. 
If there is a simple way to do what I'm looking for, I'd love if someone could point me in that direction.

otherwise-- and as will be relevant even if there is a simple way to do that, I thought I would just do it the old fashioned way and recreate my news feed in PHP like I have on my current CMS, this time with Pages' added benefit of being able to use the site skin/template as a base. 
However, I am struggling to get PHP to play nice with IP.Content. I've figured out I can do simple PHP commands and if statements by enclosing them in {{these babies}} but even trying to begin to connect directly to the database fires back a generic EX0 error. I was enclosing this line, which was how I started it on my previous CMS:

{{$link = mysql_connect('localhost', 'username', 'password') or die(mysql_error());}}

and I don't understand why that should give me an error. 

could someone give me some direction on how to treat this syntax, or otherwise a workaround to pull information from right from a MySQL database?
I should be fine once I get my proverbial sea legs here... but as it is I've been flailing. 

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

Try the following:

Quote

{{$mysqli = mysqli_connect('localhost', 'username', 'password') ;}}

You are using MySQL and not MySQLi to connect to the Database. :)

MySQL was deprecated as of php 5.5 and you should use the replacement MySQLi instead.

Link to comment
Share on other sites

  • 2 weeks later...

Oh goodness, hello! Thank you so much! I actually just happened to figure that out last night before seeing this. 
...I also found the PHP Block option a bit ago so that was kind of embarrassing that I missed that.

If I can ask one more thing, is there a certain syntax I need to use for heredocs now? in a PHP Block that is.

echo<<<HTML
           <p> words go here </p>
HTML;

That kind of thing... just adding that causes the page to crash. I thought it might also have been deprecated in PHP7? but I wasn't able to find anything searching that would have indicated as much, nor did I find anything that suggested it wouldn't work in IP.Content

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...