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> ' . $state . ' <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>';