Site Directory Should Link to Site
misfist opened this issue · 6 comments
Currently, the links for each site in the directory link to a single site entry. I think it'd be more useful for it to link to the actual site.
Maybe this means storing the site URL in the site post?
Wait, is this not something you wanted to do on the theme level?
Either way, I do think the plugin should have a function like the_site_permalink()
to link to the site that a theme could call.
I would expect that a directory would either take me directly to the site or to take me to a detail view (site directory entry) that has more detail and a link to the site. Either way, I think we need to have access to the site.
This can be done on the theme-level because we have site_directory_blog_id
. But, to get the site URL, we have to do something like this:
$blog_id = get_post_meta( get_the_ID(), 'site_directory_blog_id', true );
$blog_details = get_blog_details( $blog_id );
echo '<h2 class="entry-title"><a href="' . $blog_details->siteurl . '"> ' . the_title() . '</a></h2>';
Yeah. But we still want to leave it up to themes to define where/how to output the link to the site itself, don't we? So this is asking for a theming function like the_site_permalink()
that wraps the $blog_details->siteurl
lookup, right?
Yeah, like with any custom post type that has custom fields, the theme has to handle what to render. Having something like the_site_permalink()
would make that easier.
If widgets or shortcodes were added, there would need to be views... In that case, the plugin would decide "where/how to output the link to the site itself" (or provide a choice).
For ANP, our custom network content plugins have shortcodes and widgets so admins can include where ever they want without having to touch the theme, which they generally don't know how to do.
Having something like
the_site_permalink()
would make that easier.
Okay, so this is added in 35294b2.
For ANP, our custom network content plugins have shortcodes and widgets so admins can include where ever they want without having to touch the theme, which they generally don't know how to do.
Right, I see what you're saying, but I still think there's a certain level of control that is appropriate for the theme author. We could, for instance, add a widget to this plugin that provides a simplistic drop-down list of sites in the directory and that link to the site itself using the new the_site_permalink()
function, but that's not going to be a substitute for a taxonomy-subsite_category.php
template file, for instance.
@misfist I just learned about the get_site_url()
function. So it looks like instead of doing
$blog_details = get_blog_details($blog_id);
print $blog_details->siteurl;
we can just do
print get_site_url($blog_id);
But, and maybe this is because I'm really tired right now, does this also mean we can completely remove the custom the_site_permalink()
function from this plugin? Because that would be sweet.