Recent Topics

1 Sep 27, 2005 19:39    

You'll have to excuse me if I end up sounding like an idiot. I'm trying to code my own hack into b2evo and this is my first attempt at it.

Basically, I have an imageblog, and I added a new column to my evo_posts table to keep track of the urls of each image that I post in it. The idea is that I can pull that raw url out and use it as an image in my skin. I worked through the pain of actually being able to insert values into the new field in my database, and a quick query shows me that i've been successful.

Now I'm having a problem getting that info out of the database.

Here's my code so far, and please tell me if you need more info:

_class_item.php


...
//inside the constructor
$this->urlimage = $db_row->post_urlimage;
...
	//my function which should return the value pulled from the db
	function getImageURL(){
		$urlimage = $this->urlimage;
		echo $urlimage;
	}

_main.php


...
		<?php $saved_Blog = $Blog;		$saved_blog = $blog;  //hax
				$blog = 2; unset($Blog);  //select my imageblog
				
				echo "<div id=\"thePic\">";
				$BlogBList = & new ItemList( $blog,  '', '', '', '', '', array(), '', 'DESC', '', '', '', '', '', '', '', '', '', '1', 'posts' );  
//get the latest post in the form of an ItemList (Please don't make fun of me for doing this!)

				$Item = $BlogBList->get_item();  //pull out that item
					echo "<img src=\"" , $Item->getImageURL() , "\" alt=\"WebOser Front Page Image\" />"; 
//call the getImageURL() function, which should return $this->imageurl pulled from the database, but ends up empty for some reason

				echo "</div>";
				echo "<div id=\"theCaption\">";
					echo 'Title: ' , $Item->title() , ' | Category: ' , $Item->main_category();
				echo "</div>";
				
				$blog = $saved_blog;		$Blog = $saved_Blog;  //unhax
				?>
...

What gets me is that I know $Item contains the correct post, as other values I call from it appear correctly. And I know, from the query I'm running on the table that the value is being placed into the post_urlimage field. I'm just missing a connection somewhere.

Please help? :oops:

2 Sep 28, 2005 16:38

Stupid Oser figured out his own problem...finally...

I didn't think to look in _class_itemlist for the code that actually contains the SQL statement to pull that data from the table.

I added my new field to this line:


		$this->request = "SELECT DISTINCT ID, post_author, post_issue_date,	 post_mod_date,
																			post_status, post_locale, post_content, post_title,
																			post_urltitle, post_url, post_urlimage, post_category,
																			post_autobr, post_flags, post_wordcount, post_comments,
																			post_renderers, post_karma
											FROM ($tableposts INNER JOIN $tablepostcats ON ID = postcat_post_ID)
														INNER JOIN $tablecategories ON postcat_cat_ID = cat_ID ";

and it seems to work. All it needs is a little tweaking to get the value to display on my edit pages, and I should be in business. =)


Form is loading...