Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-05-2011, 04:17 PM   PM User | #1
sfraise
Regular Coder

 
Join Date: Mar 2009
Posts: 175
Thanks: 3
Thanked 1 Time in 1 Post
sfraise is an unknown quantity at this point
Using colorbox with dynamic url in array

I'm using colorbox to pop up a blog post in a modal window.
The problem I'm running into is the url is created in a php array and when I set the colorbox class (journalbox) it uses the last url for all of the links. I just can't think of a good way to go about getting this to work properly, maybe you guys can take a quick look at the code and think of something I'm not. Maybe there's a way to fire the link in colorbox directly from the link using an onclick or something where I don't have to define a class prior to the return? If not maybe there's a way to do this through a function?

Here's the code, the $blog_url variable and the script are the things to look at:
Code:
if ( $rows ) for ( $i = 0, $n = count( $rows ); $i < $n; $i++ ) {
			$row			=	$rows[$i];
			$blog_url		=	cbblogsClass::getPluginURL( array( 'blogs', 'show', $row->id ) );
			$edit_url		=	cbblogsClass::getPluginURL( array( 'blogs', 'edit', $row->id ) );
			$delete_url		=	cbblogsClass::getPluginURL( array( 'blogs', 'delete', $row->id ), 'Are you sure you want to delete this journal entry?', true, false, null, true );
			$publish_url	=	cbblogsClass::getPluginURL( array( 'blogs', 'publish', $row->id ), null, true, false, null, true );
			$unpublish_url	=	cbblogsClass::getPluginURL( array( 'blogs', 'unpublish', $row->id ), 'Are you sure you want to unpublish this journal entry?', true, false, null, true );
			$authorized		=	cbblogsClass::getAuthorization( $row->id );
			$position=400;
			$message="$row->blog_full"; 
			$post = substr($message, 0, $position); 
			$ender="... <!-- <br /><span class=\"rmlink\"><a href=\"#\">Read More...</a></span> -->"; 

$post = preg_replace('#</?span[^>]*>|</?p[^>]*>|</?br[^>]*>#is', '', $post);

			if ( $row->published == 1 ) {
				$state		=	'<a href="javascript: void(0);" onclick="' . $unpublish_url . '">' . cbblogsClass::getMessage( 'Unpublish' ) . '</a>';
			} else {
				$state		=	'<a href="' . $publish_url . '">' . cbblogsClass::getMessage( 'Publish' ) . '</a>';
			}

			/* $modified		=	cbFormatDate( $row->modified ); */
?>
<script type="text/javascript">
$jq(document).ready(function(){
 $jq(".journalbox").colorbox({width:"600px", height:"675px", iframe:true, href:"<?php echo $blog_url; ?>&tmpl=component"});
 $jq(".journaledit").colorbox({width:"600px", height:"675px", iframe:true, href:"<?php echo $edit_url; ?>&tmpl=component&view=edit"});
});
</script>
<?php

			$return			.=				'<div class="blogsMainContent">'
							.					'<div class="blogsMainContentInfo">'
							.						'<table width="400px"><tbody><tr><td valign="top"><div class="journaltitle">' . cbblogsClass::getMessage( array( '%s', '<a href="#" class="journalbox">' . $row->title . '</a>' ) ) . '</div>'
							.						'<div class="createdby">Posted on ' . cbblogsClass::getMessage( array( ' %s', cbFormatDate( $row->created ) ) ) . '</div></td></tr>'
							 .						'<tr><td valign="top"><div class="journalpost">' . $post . $ender . '</div>' 
							/* .						'<div>' . cbblogsClass::getMessage( array( 'Category: %s', $row->category_name ) ) . '</div>' */
							.						( $modified ? '<div>' . cbblogsClass::getMessage( array( 'Modified: %s', $modified ) ) . '</div>' : null )
							.					'</div>'
							.					'<div class="blogsMainContentMenus">'
							.						( array_intersect( array( 'blg_owner', 'usr_mod' ), $authorized ) ? '<div class="editlink"><a class="journaledit" href="#">' . cbblogsClass::getMessage( 'Edit' ) . '</a>&nbsp;' . $state . '&nbsp;<a href="javascript: void(0);" onclick="' . $delete_url . '">' . cbblogsClass::getMessage( 'Delete' ) . '</a></div>' : null )
							/* .						( array_intersect( array( 'blg_owner', 'usr_mod' ), $authorized ) ? '<div class="statelink">' . $state . '</div>' : null )
							.						( array_intersect( array( 'blg_owner', 'usr_mod' ), $authorized ) ? '<div class="deletelink"><a href="javascript: void(0);" onclick="' . $delete_url . '">' . cbblogsClass::getMessage( 'Delete' ) . '</a></div>' : null ) */
							.					'</td></tr></tbody></table></div>'
							.					'<div class="cbClr"></div>'
							.				'</div>';
sfraise is offline   Reply With Quote
Old 12-05-2011, 05:50 PM   PM User | #2
sfraise
Regular Coder

 
Join Date: Mar 2009
Posts: 175
Thanks: 3
Thanked 1 Time in 1 Post
sfraise is an unknown quantity at this point
[SOLVED]

I just added $blog_class = "journalbox".$i."";
Then just used that as the class in both the script and the a class of the link.
sfraise is offline   Reply With Quote
Reply

Bookmarks

Tags
array, colorbox, url

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:01 PM.


Advertisement
Log in to turn off these ads.