Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question regarding “archive pages” for categories and tags assigned to Media Library items. This has come up before, and you can find quite a bit of information in this earlier topic and the related topics it links to:

    Att Categories menu returns 404 error

    Briefly, the WordPress “archive pages” accessed by the kind of links you give as examples only work for Posts, Pages and Custom Post Types. The database queries that these pages start from exclude Media Library items, so they are not useful for creating the results you want. Your “list of thumbnails” is, of course, what the [mla_gallery] shortcode provides.

    You have two choices:

    1. Modify the PHP template files in your theme, replacing the database query with a version for Media Library items and the post/page list with an [mla_gallery]
    2. Create a WordPress page along the lines of the examples in the Settings/Media Library Assistant Documentation tab that contains the [mla_gallery].

    The earlier support topics address both alternatives. If you can decide which of the two alternatives is better for your application I can give you more specific help. The Template modification alternative will require modifying your theme files or creating a child theme; this can get complicated depending on your theme.

    You do not say how the {category} or {tag} term is chosen. The MLA Documentation examples use the [mla_tag_cloud] shortcode to display terms that, when clicked, pass the selected term to the [mla_gallery]. How are terms selected in your application?

    Any additional information you can give me will be helpful. Thanks for your interest in the plugin.

    Thread Starter Karastel

    (@karastel)

    I read the post above, and did everything based on your advice.
    But I do not understand how I generate the address structure like this: http://domain.com/page/category/{category}/
    &
    http://domain.com/page/tags/{tag}/

    Plugin Author David Lingren

    (@dglingren)

    Thank you for taking the time to go through the earlier topics and work out a solution. Can you tell me more about which parts of the topics you picked, i.e., did you modify the Template files or did you set up a page with shortcodes?

    Generating the address structures you give as examples can be done in a number of ways. They are the default links behind the terms displayed by [mla_tag_cloud], for example. The WordPress Categories and Tag Cloud widgets can be used for the built-n Categories and Tags taxonomies.

    The basic question is “how do you want to display the category/tag list and let the user select a term?” Have you decided that for your application?

    Thread Starter Karastel

    (@karastel)

    I modify the Template files.

    I use “[mla_tag_cloud taxonomy=attachment_category number=0]” & “[mla_tag_cloud taxonomy=attachment_tag number=0]” on page.
    You can see result here

    Plugin Author David Lingren

    (@dglingren)

    Thank you for your update with the good news about your progress and the link to your site. The images are beautiful!

    It looks like your application is working, but there is still a small problem with the pagination links at the bottom of the page; is that right? Is that what you meant by the \page\ portion of the example links you gave in your earlier post?

    If you would like help with pagination, I will need to see your template file. You can post it here or give me your contact information and I will respond with an address where you can e-mail the template file to me. You can use the Contact Us page at our web site:

    Fair Trade Judaica/Contact Us

    Please let me know if you need more assistance. Thanks for your patience.

    Thread Starter Karastel

    (@karastel)

    Thank you very much for your help!

    Problem №1
    I’m trying to get this result:
    http://domain.com/photo_albums/category/{category}/
    http://domain.com/photo_albums/tags/{tag}/
    where:
    {category} – page with media files linked to a specific category.

    But now I have this result:
    http://domain.com/attachment_category/{category}/
    http://fresh-trip.ru/attachment_tag/{tag}/

    Problem №2
    I need to get all the images in the selected category as thumbnails on a single page (pagination is not needed).

    Also, I need:

    • a link to the full-size image
    • photo title,
    • photo caption,
    • alt attribute,
    • link to image attachment page,
    • html code like in my gallery by default.

    For example:

    <a href="{full_size_image}" title="{image_title}"> <img src = "{thumbnail_image}" alt = "{alt_text}"> </a>
    <p> {image_caption} </ p>
    <a href="{image_attachment_page}">comments</a>

    my templates
    taxonomy.php

    <?php
    get_header(); 
    
    global $wp_query;
    
    $is_media_archive = in_array( $wp_query->query_vars['taxonomy'], array( 'attachment_category', 'attachment_tag' ) );
    if ( $is_media_archive ) {
    	if ( isset( $_REQUEST['use_mla_gallery'] ) ) {
    		$use_mla_gallery = true;
    	} else {
    		$use_mla_gallery = false;
    		$args = array_merge( $wp_query->query_vars, array( 'post_type' => 'attachment', 'post_status' => 'inherit' ) );
    		query_posts( $args );
    	}
    }
    
    ?>
    		<section id="container">
    			<div id="content" role="main">
    
    			<?php cryout_before_content_hook(); ?>
    
    					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<?php cryout_post_title_hook(); ?>
                        <?php wp_link_pages( array( 'before' => '<div class="page-link"><span class="b">Pages:</span>', 'after' => '</div>' ) ); ?>
    					<h1 class="entry-title"><?php echo $wp_query->query_vars['term']; ?></h1>
    					<div class="entry-content"><?php echo do_shortcode( '[mla_tag_cloud taxonomy=attachment_category number=0]'); ?>
    
    <?php
    //Option №1
    echo do_shortcode( sprintf( '[mla_gallery %1$s="%2$s" link="file" mla_alt_shortcode="gallery" ]', $wp_query->query_vars['taxonomy'], $wp_query->query_vars['term'] ) ); 
    
    //Option №2
    while ( have_posts() ) : the_post();
    	if ( $is_media_archive ) {
    		get_template_part( 'content', 'media' );
    			} else {
    				get_template_part( 'content', get_post_format() );
    			}
    		endwhile;
    
    mantra_content_nav( 'nav-below' );
    ?>
    
    						<?php wp_link_pages( array( 'before' => '<div class="page-link"><span class="b">PAges:</span>', 'after' => '</div>' ) ); ?>
    					</div><!-- .entry-content -->
    
    					<div class="entry-utility">
    						<?php mantra_posted_in(); ?>
    					</div><!-- .entry-utility -->
    
    				</div><!-- #post-## -->
    
    				<?php comments_template( '', true ); ?>
    
    			<?php cryout_after_content_hook(); ?>
    			</div><!-- #content -->
    	<?php get_sidebar(); ?>
    		</section><!-- #container -->
    <?php get_footer(); ?>

    content-media.php

    <?php
    global $post;
    ?>
    
    	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<div class="entry-content">
    
    			<?php the_content(); ?>
    		</div><!-- .entry-content -->
    
    		<footer class="entry-meta">
    			<a href="<?php the_permalink(); ?>" rel="bookmark">
    				<h1><?php the_title(); ?></h1>
    				<h2><time class="entry-date" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo get_the_date(); ?></time></h2>
    			</a>
    			<?php if ( comments_open() ) : ?>
    			<div class="comments-link">
    				<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'mantra' ) . '</span>', __( '1 Reply', 'mantra' ), __( '% Replies', 'mantra' ) ); ?>
    			</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>
    			<?php edit_post_link( __( 'Edit', 'mantra' ), '<span class="edit-link">', '</span>' ); ?>
    		</footer><!-- .entry-meta -->
    	</article><!-- #post -->

    When I use the Option №1, I get:

    • a link to the full-size image,
    • photo title,
    • photo caption,
    • alt attribute.

    But do not get a link to image attachment page.

    When I use the Option №2, I get:

    • a link to the full-size image
    • photo title,
    • photo caption,
    • alt attribute,
    • link to image attachment page,

    But do not get a thumbnails-size image.
    And have paginated page with not working paginated links.


    Perhaps the right way to solve the second problem – change output gallery by default (add link to image attachment page).
    But I do not know where to change that. ((

    This problem is not related to your plug-in, so I asked about the problem №1. 🙂

    —-
    P.S. Sorry for my english.
    P.P.S. I’ve downloaded the template with two options on my site. You can see the result.

    Plugin Author David Lingren

    (@dglingren)

    Your English is fine – much better than my Russian! Thanks for taking the time to include the template files; very helpful.

    First I want to make sure I understand your Problem No. 1; you wrote:

    Problem №1

    I’m trying to get this result:
    http://domain.com/photo_albums/category/{category}/
    http://domain.com/photo_albums/tags/{tag}/
    where:
    {category} – page with media files linked to a specific category.

    But now I have this result:
    http://domain.com/attachment_category/{category}/
    http://fresh-trip.ru/attachment_tag/{tag}/

    When you write “I have this result” are you referring to the links behind each term in your [mla_tag_cloud]? If so, I can show you how to change them.

    In the results you want you show the taxonomy portion as category and tags (which should be post_tag, I think). Do you really mean the WordPress built-in “Categories” and “Tags” taxonomies? Your cloud is based on the attachment_category and attachment_tag taxonomies; you need to use the same taxonomy in the cloud and in your links. Are you using all four taxonomies in your site?

    I did a few tests and I could not get any results under the http://domain.com/photo_albums/ part of the site. Have you created pages under /photo_albums/? Is there another reason for adding this level to the URLs?

    Regarding your Problem No. 2, I had a quick look at your templates. Your Option No1 includes this statement:

    echo do_shortcode( sprintf( '[mla_gallery %1$s="%2$s" link="file" mla_alt_shortcode="gallery" ]', $wp_query->query_vars['taxonomy'], $wp_query->query_vars['term'] ) );

    I am not sure why you are using mla_alt_shortcode="gallery". This is using [mla_gallery] for selecting the images and then handing control to the gallery shortcode to format the display. It looks like you are using some other “lightbox” plugin to format the display. I can tell you how to get the content you want using [mla_gallery] but it will not help unless you remove the mla_alt_shortcode parameter and let [mla_gallery] format the display. Would that be possible?

    Thread Starter Karastel

    (@karastel)

    Problem №1

    When you write “I have this result” are you referring to the links behind each term in your [mla_tag_cloud]? If so, I can show you how to change them.

    Yes, I mean the links behind each term [mla_tag_cloud].

    In the results you want you show the taxonomy portion as category and tags (which should be post_tag, I think). Do you really mean the WordPress built-in “Categories” and “Tags” taxonomies? Your cloud is based on the attachment_category and attachment_tag taxonomies; you need to use the same taxonomy in the cloud and in your links. Are you using all four taxonomies in your site?

    No, I mean attachment_category and attachment_tag taxonomies.

    I did a few tests and I could not get any results under the http://domain.com/photo_albums/ part of the site. Have you created pages under /photo_albums/? Is there another reason for adding this level to the URLs?

    photo_albums is a page. I don’t create pages under photo_albums.

    Problem №2

    I can tell you how to get the content you want using [mla_gallery] but it will not help unless you remove the mla_alt_shortcode parameter and let [mla_gallery] format the display. Would that be possible?

    Yes, it’s possible. I delete mla_alt_shortcode parameter. Help me get content, please.

    Plugin Author David Lingren

    (@dglingren)

    Thank you for your answers, the additional templates and the link to your sample page. I have gone back over all the posts in this topic and I now realize the simplest way to get the results you want is to put all of the shortcodes directly in the photo_albums page. Here is a solution that does not require any modifications to URLs or to your Template files:

    Click on a term in either clould to populate the gallery below.
    
    <h3>The Att. Category Cloud</h3>
    [mla_tag_cloud taxonomy=attachment_category number=0 mla_link_href="{+page_url+}?taxonomy_slug={+taxonomy+}&term_slug={+slug+}"]
    
    <h3>The Att. Tag Cloud</h3>
    [mla_tag_cloud taxonomy=attachment_tag number=0 mla_link_href="{+page_url+}?taxonomy_slug={+taxonomy+}&term_slug={+slug+}"]
    
    <h3>The Gallery</h3>
    [mla_gallery tax_query="array(array('taxonomy'=>'{+request:taxonomy_slug+}','field'=>'slug','terms'=>'{+request:term_slug+}'))" mla_nolink_text="No pages to show." posts_per_page=10 mla_output="paginate_links,prev_next" mla_link_href="{+page_url+}?term_slug={+request:term_slug+}&taxonomy_slug={+request:taxonomy_slug+}"]
    
    [mla_gallery tax_query="array(array('taxonomy'=>'{+request:taxonomy_slug+}','field'=>'slug','terms'=>'{+request:term_slug+}'))" mla_nolink_text="Click a term to display the gallery." posts_per_page=10]

    In the above example the taxonomy and term values are passed as query attributes (taxonomy_clug and term_slug) and not as part of the URL. I regret not working this out sooner and saving you the work required to modify your template files. I hope this solved your Problem No1. If you do not need pagination, remove the first [mla_gallery] shortcode and the posts_per_page=10 parameter in the second shortcode.

    Regarding your Problem No2,can I use the HTML in your option No2 (the <article> list) as my guide? Do you want to include the entry-date and rel=bookmark and so on?

    Thread Starter Karastel

    (@karastel)

    Thank you for your help!

    Problem №1
    You have sent a solution in which the page is generated through the transmission parameters in the address bar.
    I want to use semantic URL, such as:
    http://domain.com/photo_albums/attachment_category/{category}/
    http://domain.com/photo_albums/attachment_tag/{tag}/

    Problem №2
    Yes, you can use HTML.

    Do you want to include the entry-date and rel=bookmark and so on?

    Yes, it would be nice!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for clarifying your requirements for Problem No1. If you really need a “semantic URL” you will have to work with the URL rewrite rules in your .htaccess file. I do not have any experience with rewrite rules and I regret that I cannot give you any further guidance on how to proceed. You may find some useful information in these earlier MLA support topics:

    rewrite custom taxonomy slug?

    Pagination

    You should also review this Codex article:

    Using Permalinks

    Good luck with this part of your application. If you come up with anything of general interest I encourage you to post it here so others can benefit.

    Regarding your Problem No2, I can make some suggestions on modifications to your “Option No1” [mla_gallery] shortcode.

    First, you can turn your image caption into a “link to the image attachment page” by adding an mla_caption parameter to your shortcode. Try something like this:

    mla_caption='<a rel="bookmark" href="{+pagelink_url+}" tooltip="{+title+}">{+excerpt+}</a>'

    In this example, {+pagelink_url+}, {+title+} and {+excerpt+} are item-level substitution parameters. You can find all of the available substitution parameters in the “Attachment-specific substitution parameters for the markup template Item part” section of the Settings/Media Library Assistant Documentation tab.

    For your Option No2, the HTML inside the <div class="entry-content"> tag comes from the WordPress page source (<?php the_content(); ?>) which I do not have so I cannot tell exactly how the data-imgid="0" and data-postid="fsg_post_2432" attributes are generated. Once you calculate the appropriate values you can add these attributes to the thumbnail hyperlink by adding an mla_link_attributes parameter to your shortcode. Try something like this:

    mla_link_attributes='data-imgid="0" data-postid="fsg_post_2432"'

    Here is a code example that adds both of the above parameters to your Option No1 do_shortcode statement in taxonomy.php:

    <?php
    //Option №1
    
    $data_imgid = '0'; // or whatever value your application needs
    $data_postid = 'fsg_post_2432'; // or whatever value your application needs
    
    $mla_link_attributes = sprintf( 'data-imgid="%1$s" data-postid="%2$s"', $data_imgid, $data_postid );
    $mla_caption = '<a rel="bookmark" href="{+pagelink_url+}" tooltip="{+title+}">{+excerpt+}</a>';
    
    echo do_shortcode( sprintf( '[mla_gallery %1$s="%2$s" mla_link_attributes=\'%3$s\' mla_caption=\'%4$s\' link="file" mla_alt_shortcode="gallery" ]', $wp_query->query_vars['taxonomy'], $wp_query->query_vars['term'], $mla_link_attributes, $mla_caption ) );
    ?>

    I broke the code into three steps for clarity; you can re-arrange it as you need to.

    If this is the only place you need to modify your [mla_gallery], adding the parameters to your shortcode makes sense. The other approach would be to set up a custom markup template with the modifications in the template code. You can find information on that in the “MLA Gallery Style and Markup Templates” of the Documentation.

    Plugin Author David Lingren

    (@dglingren)

    It has been a month since my last post in this topic. I assume you have found a solution to the application requirements we had been working on.

    I am marking this topic resolved, but please update it or start a new topic if you have any further questions regarding the plugin.

    Thread Starter Karastel

    (@karastel)

    I apologize for not being answered. Any problems and did not have time to engage in a personal project. ((

    I have not found a way to make Semantic URL.

    In the end, I left this variant: http://fresh-trip.com/photo-albums/?taxonomy_slug=attachment_category&term_slug=ryby

    [mla_tag_cloud taxonomy=attachment_category number=0 mla_link_href="{+page_url+}?taxonomy_slug={+taxonomy+}&term_slug={+slug+}"]
    
    [mla_gallery tax_query="array(array('taxonomy'=>'{+request:taxonomy_slug+}','field'=>'slug','terms'=>'{+request:term_slug+}'))" mla_nolink_text="No pages to show." posts_per_page=99 mla_output="paginate_links,prev_next" mla_link_href="{+page_url+}?term_slug={+request:term_slug+}&taxonomy_slug={+request:taxonomy_slug+}"]
    
    [mla_gallery tax_query="array(array('taxonomy'=>'{+request:taxonomy_slug+}','field'=>'slug','terms'=>'{+request:term_slug+}'))" mla_nolink_text="Click a term to display the gallery." posts_per_page=99 link="file"]
    Thread Starter Karastel

    (@karastel)

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the current status of the “semantic URL” issue. If I ever get a chance to learn about URL rewrite rules I will let you know.

    I am responding to your two other topics in their own threads.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘custom urls’ is closed to new replies.