mgsisk / webcomic

Comic publishing power for the web. Turn your WordPress-powered site into a comic publishing platform with Webcomic.
http://wordpress.org/plugins/webcomic
GNU General Public License v2.0
110 stars 29 forks source link

Template Shortcodes #114

Closed Kuriousity closed 11 years ago

Kuriousity commented 11 years ago

I'm currently putting together a site using the Webcomic plug-in that it displaying mulitple comics, and I'm having trouble finding short codes to use for a couple things. I've gone through and tried many of the given Template Tags and Shortcodes, plus tried guessing some, but haven't had any luck.

I'm looking for shortcodes that:

Examples: Every page has navigation links for Home/Archive & Characters, and depending on which comic you have open, the link should lead to the specific page for that comic. I can get it to pull in the poster/logo and comic descriptions into the layout without problem, but can't seem to figure out these automated links.

If I could have a php code that enters a collection slug, that would be a huge help to doing all this as well. Currently I can only get the collection name to work, which only works as a slug if the webcomic is a single word title.

These seem like they'd be pretty standard options, so I may just be missing something obvious, but any help is appreciated!

mgsisk commented 11 years ago

I'm not sure I completely follow what you're trying to do; can you provide more details? Where do the Archive and Character links appear? Are you talking about the WordPress-generated post type and term archives, or pages you have created to be the "Home/Archive" and "Character" pages? Are you actually trying to use shortcodes (e.g. in a post content body) for these or template tags?

Kuriousity commented 11 years ago

Sorry I wasn't clear, I'll try to explain it a bit better.

I'm making a webpage with multiple web comics. Each one is its own Collection. All pages on the site have the same layout with the same content navigation options, but these options need to lead to different places depending on the webcomic being read (ie: Archive will lead to the archive of that specific webcomic).

A prime example is that I'm using Collection posters as a logo in the header to show readers which webcomic they are reading. I would like them to be able to click the logo and be taken to the index archive of that webcomic, but I can't seem to figure out a way to make those links automatic like the logo itself is.

I did find a few workarounds, but they all require a way to bring in a web comic collection's slug. You have PHP options for bringing in things such as collection names, character lists, etc., but is there a way to call the slug?

Also I haven't had any luck getting a dropdown menu of a collection's comics to work. I can get it to list storylines but not the comics themselves. Is this an option?

mgsisk commented 11 years ago

When you say collection slug I assume you mean the post type ID, which you can get using get_webcomic_collection(). The webcomic_dropdown_collections() template tag will generate a dropdown of a collections webcomics (this is the third example on that page, modified to use get_webcomic_collection() instead of hard-coding the collection ID):

webcomic_dropdown_collections( array( 'collection' => get_webcomic_collection(), 'webcomics' => true ) );
Kuriousity commented 11 years ago

Thanks, that dropdown menu code worked!

Unfortunately I'm still not able to call a webcomic's slug (the one I get to choose in the web comic's settings). Using php webcomic_collection_title(); works, but get_webcomic_collection() calls up nothing. I was hoping I could use webcomic_collection_slug(); but unfortunately it doesn't pull any information either.

mgsisk commented 11 years ago

There's no template tag or shortcode for retrieving the collection slug, but you can pull it directly from the collection configuration, like:

$collection_config = get_webcomic_collection( true );

echo $collection_config[ 'slugs' ][ 'name' ];

Out of curiosity: what do you need the collection slug for? It's used very rarely in Webcomic itself, and shouldn't be necessary for any functions.

Kuriousity commented 11 years ago

I'm using it to automate navigation links.

For example (with some symbols removed so the code appears):

<a href="http://www.domain.com/<?php webcomic_collection_title(); ?>"><?php webcomic_collection_poster(); ?></a>

Creates a logo with a link to that comic's main page. This code is on every page of the site, so it automates to whichever webcomic the reader is reading. This also includes information pages such as this:

<nav>
<li><a href="http://www.domain.com/<?php webcomic_collection_title(); ?>">Comic</a>/li>
<li><a href="http://www.domain.com/cast/<?php webcomic_collection_title(); ?>">Cast</a>/li>
<li><a href="http://www.domain.com/about/<?php webcomic_collection_title(); ?>">About</a>/li>
<li><a href="http://www.domain.com/extras/<?php webcomic_collection_title(); ?>">Extras</a>/li>
</nav>

As you can see I'm currently using the comic title, but it's a really clunky use and forces me to title all comics with one word, which makes using the title tag useless elsewhere if that's not the accurate name of the comic.

I'm not able to call in the slug with the code you gave me - it doesn't cause any PHP errors but doesn't bring anything in either. Not sure what I'm doing wrong.

mgsisk commented 11 years ago

There's a mixup in the get_webcomic_collections() function that prevents that from working at the moment. Try changing line 26 in webcomic/-/php/tags.php from this:

return ( $config and isset( self::$config[ 'collections' ][ self::$collection ] ) ) ? array( self::$collection => self::$config[ 'collections' ][ self::$collection ] ) : self::$collection;

to this:

return ( $config and isset( self::$config[ 'collections' ][ self::$collection ] ) ) ? self::$config[ 'collections' ][ self::$collection ] : self::$collection;
Kuriousity commented 11 years ago

That worked perfectly - thank you :)