I wrote a post here a few days ago explaining how I'd integrated ZenPhoto into my Wordpress blog. Now I´ve gone a bit further and tweaked it so ZenPhoto uses my Wordpress authentication, all Wordpress users (except Subscribers) can now access the ZenPhoto administration with their WP user/pass. If anyone is interested, a short tutorial on how to do this can be found at:
http://tech.einaregilsson.com/2007/08/08/using-wordpress-authentication-in-zenphoto/
Comments
Maybe you should write a real wp plugin...:-)
For now though, this works like a charm. Thanks!
I'm wondering if you know how to get a tab for my gallery to show up in the main WordPress site navigation? I've been looking around, and there doesn't seem to be an easy way, but maybe i'm missing something. Thanks!
Now if I could just get that tab to stay highlighted when I click through into zenphoto albums and image pages...
@dspnorman: The only thing I can think of to highlight the current page is to figure out what WP uses to determine whether to highlight it, and possible alter $_GET[] or something so WP thinks it's on that page.
Something like $_GET['p'] = 123; //where 123 is the postID of the empty gallery page
is all I can think of. If you tell me what theme you're using I might be able to figure it out
I've hacked it for now by adding a rule to the zen-style.css which uses an attribute selector to get the "gallery" tab, and then if the link in that tab is visited (i.e. if I'm on a gallery page) it applies the same styling to mark the tab as current. Only problem is, that means the CSS is in two places.
It works though, and I have no idea how to hack the WP theme to make it add that extra class when on a gallery sub page, since it's all done in the WP header.
if (substr($_SERVER['REQUEST_URI'],0, 9) == '/gallery/) {
return 123; //where 123 is the post id of your gallery page
}
I think that would work, although I haven't tested it. Otherwise if you want this function to return the correct value you'll have to load the post somehow and I have no idea how to do that. But if your css thing works then thats probably the easiest way to do it.
However, on the (mt) server, I get an error when trying to view or login to the gallery pages:
`Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /mnt/xx/xx/xx/domains/xxx/html/pictures/zen/auth_zp.php on line 14`
Here's what's on the that line in my file: `return is_user_logged_in() && wp_get_current_user()->user_level >= 2;`
As I said, there's no difference between this file and one that's working on another server, and even the directory structure is the same... anyone know of pickiness with Media Temple's PHP implementation?
$is_logged_in = is_user_logged_in();
if (!$is_user_logged_in)
{
return false;
}
$user = wp_get_current_user();
$level = $user->user_level;
return $level >= 2;
Havent tested it, but this should at least give you a clearer picture of what's not working.
To highlight the current page I did this:
my wordpress is in www.bertsimons.nl/wordpress
my zenphoto is in www.bertsimons.nl/zenphoto
following:
$page = $_SERVER['REQUEST_URI'];
$page = str_replace("/","",$page);
will in my case now return: ' zenphoto' or 'wordpress'
in my wordpress header I now put:
<?php //highlight wordpress pages or zenphoto
$page = $_SERVER['REQUEST_URI'];
$page = str_replace("/","",$page);
if ($page == "wordpress") {
$page = "zenphotouit";
$highlight = "wordpress";
} else {
$highlight = "wordpressuit";
$page = "zenphoto";
}
if (is_page()) {
$page = "zenphotouit";
$highlight = "wordpressuit";
}
if (is_single()) {
$page = "zenphotouit";
$highlight = "wordpress";
}
if (is_category()) {
$page = "zenphotouit";
$highlight = "wordpress";
}
if (is_archive()) {
$page = "zenphotouit";
$highlight = "wordpress";
}
?>
and the string $higlight and $page are classes to put in my navigation bar which I also define in my wordpress header.php
<div>
<ul id="supernav">
<li class="<?php echo $page; ?>">Portfolio</class>
<li class="<?php echo $highlight; ?>">">Blog</class>
<?php wp_list_pages('title_li='); ?>
</div>
the classes I defined in my wordpress style.css
('uit' is dutch for 'off')
#supernav a {
color:#858585;}
#supernav .zenphoto a {color:#fff;}
#supernav .zenphotouit a {color:#858585;}
#supernav .wordpress a {color:#fff;}
#supernav .wordpressuit a {color:#858585;}
#supernav page_item a {color:#858585;}
#supernav .current_page_item a {color:#fff;}
note; the .current_page_item a and page_item a class are classe defined by the <?php wp_list_pages('title_li='); ?> tag.
hope this is usefull.
In my blog I use Zenpress to insert a photo from an zenphoto album in wordpress.
clicking the image takes me to the corresponding album.
In the zenphoto image description I would like to see the cooresponding wordpress post text..
I manage to get all posts in there when using
<?php while (have_posts()) : the_post(); ?><?php the_excerpt(); ?><?php endwhile; ?>
but not the single post I was on in wordpress..
any ideas?
$url = 'your image url here';
$rs = $wpdb->get_results("select post_content from posts where post_content like '%$url%', ARRAY_A);
$text = $rs['post_content'];
Something like that maybe. Haven't tested it. Or am I completely misunderstanding what you're asking for?
and thanks alot for pointing me in the right direction! I got it working!
for now I made something like this, I could get it working with getFullImageUrl() probably because of my lack of php writing skills to properly add quuotes, ots etc in teh right place...
<?php
$url = getImageTitle();
$sql = "select post_content, post_title from wp_posts WHERE post_content REGEXP '".$url."'";
$zen_wpcontent = array();
$zen_wpcontent2 = array();
$results = $wpdb->get_results($sql );
foreach( $results as $result )
$zen_wpcontent[] = $result->post_title;
$zen_wpcontent2[] = $result->post_content;
for($x=0;$x<count($zen_wpcontent);$x++)
{
echo $zen_wpcontent[$x]; echo "<br><br>";
echo $zen_wpcontent2[$x];
echo " ";
}
?>
and to hide image from the original post_content I just added a class image: display none; to the css
thanks a lot!
<?php
$url = getImageTitle();
$sql = "select post_content, ID, guid, post_title from wp_posts WHERE post_content REGEXP '".$url."'";
$results = $wpdb->get_results($sql );
foreach( $results as $result ){
$zen_wpID[] = $result->ID;}
for($x=0;$x<count($zen_wpID);$x++){
$post_id = get_post($zen_wpID[$x]);
$zen_wptitle = $post_id->post_title;
$zen_wpcontent = $post_id->post_content;
$zen_wpguid = $post_id->guid;}
?>
<?php
$url = getFullimageurl() ;
$url = str_replace('/albums','',$url);
$sql = "select post_content, ID, guid, post_title from wp_posts WHERE post_content LIKE '%".$url."%'";
$results = $wpdb->get_results($sql );
foreach( $results as $result )
{
$zen_wpID[] = $result->ID;
}
for($x=0;$x<count($zen_wpID);$x++)
{
$post_id = get_post($zen_wpID[$x]);
$zen_wptitle = $post_id->post_title;
$zen_wpcontent = $post_id->post_content;
$zen_wpguid = $post_id->guid;
}