Jump to content

A Bit of Integration


Michael

Recommended Posts

Forgive me if I've created a thread someone's already started, but I can't find information about what I'm specifically looking for. Hopefully you guys can help!

If I understand correctly, phpVMS is supposed to be the full package - you upload it to the root of your website, customize the looks of it, and BAM! you've got yourself an operational virtual airline complete with everything a pilot or admin needs to keep it running. I love what I've seen so far because I know this is a powerful tool, and I didn't even have to pay for it! But, I want to use phpVMS separately from my main site (if I'm saying that right). I have a look I'm going for, and I'm not sure I'm good enough to manipulate a skin to fit phpVMS. I want to use the pilot center, but I would also like to use information generated by phpVMS elsewhere.

So, what I'm wanting to do is bring elements and put them on various parts of my site, like what I've already done with the login feature on the main sidebar.

When you aren't logged in to the Pilot Center, you get this:

LoggedOut.PNG

And when you are logged in, this shows:

LoggedIn.PNG

It works great. When you login, it takes you to the pilot center, which is what I want. But, as you navigate away from the pilot center onto the main part of the site, your information goes with you.

Now, instead of updating index.php every time I post a new news post or want to get a different message across the home page, I would like to post the News feature in phpVMS. I'll admit real quick that I'm good at recognizing what code does what, and I can manipulate it to work properly, but I really don't know squat, and the code is where I'm having the issue.

Here is what I used when I put in the pilot/login information:

  • Lines 3-9
    <?php 
    ob_start();
    include_once realpath(dirname(__FILE__)."/pilots/core/codon.config.php");
    ?>


  • Lines 169 - 218
    <?php 
    	/* 
    	Quick example of how to see if they're logged in or not
    	Only show this login form if they're logged in */
    	if(Auth::LoggedIn() == false)
    	{ ?>
                  <form name="loginform" action="http://simulatedvirgin.com/pilots/index.php/login" method="post">
    			<p></p>
    			<p><br />
    			  <strong>Pilot ID</strong> <em>or</em> <strong>Email</strong>:<br /> 
    			  <input type="text" name="email" onClick="this.value=''" />
    		  </p>
    		  <p> </p>
    			<p>
    			 <strong>Password</strong>:<br /><input type="password" name="password" value="" /><br /><br />
    			  <input type="hidden" name="remember" value="on" />
    			  <input type="hidden" name="redir" value="index.php/profile" />
    			  <input type="hidden" name="action" value="login" />
    			  <input type="submit" name="submit" class="button" value="Log In" />
                 </p>
               </form>
               </div>
               <?php
    	}	
    	/* End the Auth::LoggedIn() if */
    	else /* else - they're logged in, so show some info about the pilot, and a few links */
    	{
    
    	/*	Auth::$userinfo has the information about the user currently logged in
    		We will use this next line - this gets their full pilot id, formatted properly */
    	$pilotid = PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid);
    	?>
    
    	<img align="left" height="50px" width="50px" style="margin-right: 10px;"
    		src="<?php echo PilotData::getPilotAvatar($pilotid);?>" />
    
    	<strong>Pilot ID: </strong> <?php echo $pilotid ; ?><br />
    	<strong>Rank: </strong><?php echo Auth::$userinfo->rank;?><br />
    	<strong>Total Flights: </strong><?php echo Auth::$userinfo->totalflights?> <br /> 
           <strong>Total Hours: </strong><?php echo Auth::$userinfo->totalhours;?>
    	<br /><br /><br /></div>
           <dl class="nav3-grid">
           <dt><a href="<?php echo url('/pireps/new');?>">File a New PIREP</a></dt>
           <dt><a href="<?php echo url('/schedules/bids');?>">View My Bids</a></dt>
           <dt><a href="<?php echo url('/profile/');?>">View Pilot Center</a></dt>
           <dt><a href="http://simulatedvirgin.com/pilots/index.php/logout">Logout</a></dt>
           </dl>
    	<?php
    	} /* End the else */
    	?>


Now, that works. But, when I add the following to the same page as to integrate the News feature, I get an error:

<? class News extends CodonModule
{
public function index()
{
	$this->ShowNewsFront(5);
}

// This function gets called directly in the template
public function ShowNewsFront($count=5)
{
	$sql='SELECT id, subject, body, postedby, UNIX_TIMESTAMP(postdate) AS postdate
			FROM ' . TABLE_PREFIX .'news 
			ORDER BY postdate DESC 
			LIMIT '.$count;

	$res = DB::get_results($sql);

	if(!$res)
		return;

	foreach($res as $row)
	{
		//TODO: change the date format to a setting in panel
		$this->set('subject', $row->subject);
		$this->set('body', $row->body);
		$this->set('postedby', $row->postedby);
		$this->set('postdate', date(DATE_FORMAT, $row->postdate));

		$this->show('news_newsitem.tpl');
	}
}
} ?>

And the error is:

Fatal error: Cannot redeclare class News in /homepages/11/d329479458/htdocs/index.php on line 242

I'll admit to copy and pasting. But, I'd like to know what exactly is going wrong... maybe it won't work altogether? Anyway, here's what the site looks like. The link is in my signature, but the look and circumstance may change.

Site.png

Am I making sense? I know this is one little issue, but I see it repeating itself as the code all looks similar.

Thanks for your time!

Link to comment
Share on other sites

  • Moderators

HI,

I have just been looking at your site and personally seaking i think it would be easier to filly move over to vms and skin your site in the way you currently have with out too much problems.

I dont know what you have in the back end but phpvms is very friendly to customize if you have some basic css knowledge.

Link to comment
Share on other sites

  • Administrators

Once you call codon.config.php, the entire engine and modules are all loaded in.

So in that case, the News module is already loaded - you can just call the module using:

MainController::Run('News', 'ShowNewsFront', 10); // show 10 stories

That's probably what you're looking for. But I agree with mark, it'll be much easier to skin phpVMS to go however you like - some people do use something like Joomla and phpVMS, and just skin both to look the same.

Link to comment
Share on other sites

  • Administrators

Hey, I appreciate the replies. I'm going to look into skinning... I think I get too impatient, but I'm going to take the time to read up on it and tinker around.

Again, much apreciated.

Yup, I understand it's a little annoying at first but once you learn it it goes by pretty quick.

It's almost the same as editing a template in Dreamweaver

Link to comment
Share on other sites

Yup, I understand it's a little annoying at first but once you learn it it goes by pretty quick.

It's almost the same as editing a template in Dreamweaver

I'm actually using Dreamweaver to do the tweaking, and I think I'm catching on. I think I was used to one headache, and didn't want to risk another one. But, this isn't as complicated as I thought it would be, which is a releaf. I'm still trying to figure out a few things, but I think I can figure most of it out.

PS - How do I get the navigation links to have first letter capitol? =)

Thanks again.

Link to comment
Share on other sites

  • Administrators

I'm actually using Dreamweaver to do the tweaking, and I think I'm catching on. I think I was used to one headache, and didn't want to risk another one. But, this isn't as complicated as I thought it would be, which is a releaf. I'm still trying to figure out a few things, but I think I can figure most of it out.

PS - How do I get the navigation links to have first letter capitol? =)

Thanks again.

That's a CSS rule, to lower-case it

Link to comment
Share on other sites

That's a CSS rule, to lower-case it

Yeah, I found it. After I changed it, I didn't know if I like it any better, but I figured after searching for it, I'd just leave it. ;)

Didn't take long at all to figure out how everything is laid out. I'm on a roll! I figured it would take some time to set things up. At the pace I'm going now, in the same amount of time, I'm either going to run out of things to do, or I'm going to beat my expectations. Or, maybe I'll be done early, who knows.

I've been coming over to the forum when I get tired at staring at the code and such (remember, I really don't know what I'm doing). I'm learning a lot, fast!

Thanks a bunch for the help.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...