Problem with items displaying on custom theme

Hi all,

I’m using the Tainacan plugin on my library’s website. I can’t use the Tainacan theme or Blocksy as the repository pages need to match the style of the rest of the website, which is apparently not compatible.

I followed the directions on the Creating Custom Themes page, but I’m having trouble getting things to display. The /collections page and the /[collection-name] pages only show the headings, not any of the collections or items:

But if I go to the single item page, it displays as it should:

I think I have all of the files I need uploaded, because if I switch my theme to Twenty-Twenty or Blocksy, everything displays correctly. Can anyone help me figure out what I’m doing wrong?

Tainacan only works with the Tainacan Theme or Blocksy. If you’re going with Blocksy, you’ll need to install the “Tainacan Blocksy” plugin. If you can’t use these themes, you’ll have to build pages using Gutenberg blocks.

The Tainacan website and Wiki directions imply otherwise. I followed the directions provided in the wiki and they sort of worked, except for the Collections pages.

Can anyone tell me what the specific PHP files are that correspond to the Collections, Items and Taxonomy terms pages? If I knew which file was generating which page, I think I could troubleshoot this more efficiently.

Hi @joannep, welcome to our forum!

I’m sorry for the very late answer, I was off for vacations.

As explained in the wiki, you can create custom templates via child themes. The gutenberg approach mentioned by @marcos.sigismundo is the way to go if you don’t have access or knowledge to edit theme files.
There are some pages/templates that you might be interested on overriding:

The collection items list, repository items list or taxonomy term items list are archives where you’ll probably want to use the faceted search function. As explained in the wiki, you should have files inside a tainacan folder inside your theme. For example, for the collection items list, create a tainacan/archive-items.php file in the theme and there place a call to the tainacan_the_faceted_search() function. A good place to look how this work is in the source code of the Tainacan Interface theme itself:

The item single page already displays some information because the plugin override the WordPress default template hierarchy to put those elements there. To override or customize the same information, you would have to create a file tainacan/single-items.php. The content here is a bit more complex, as we’re pulling different information (attachments, metadata, related items, etc.). Again the Tainacan Interface source code can help but I can give you more details if you explain me how do you expect things.

The collections list it self does not offer much to be done, it is basically a archive that lists your collections as posts. You may want to display extra information there but to fetch this information you might need a bit more knowledge on Tainacan internals API (such as displaying the amount of items each collection has). To override your theme default template, simply place a archive-tainacan-collection.php file in the root of your theme folder.

Looking at your links, it seems that some collections and items are being displayed. If you need more help, please show me how the code is organized so we can check if there is anything missing.

Hi Mateus,

Sorry for the delayed response - I was out on leave.

Thank you for the clarifications - that helped me fixed a couple of the problems. The Collection items page is working now.

The main collections list is still a problem, though it seems like it’s trying to load the right info:

This is what I want it to resemble, but with my custom theme headers, colors, etc:

I added the archive-tainacan-collection.php file to my child theme folder. Should it go in the parent theme folder?

Let me know if that helps you see where the problem is.
Thanks!
Joanne

Hi @joannep!

If you are doing a direct copy of the Tainacan Interface source code files, you have to keep in mind that there might be more to it. For example, in this line:

It is calling for another file that is inside the template-parts/loop-raiancan-collection.php file, which should also exist. And the HTML there is populated with a bunch of CSS classes that are styled in the theme CSS files… so it is not that simple. You must either implement it yourself or, in case you can leave with your theme default post-like listing, remove the file so that the default archive template is rendered.

Hi Mateus!

Coming back around to this after a bit…I was able to get everything working except for the individual item pages. When I click on an item in the repository, the page comes up blank in the content area.

After trying everything I could think of, I switched from my custom theme to Blocksy, as everything is supposed to be compatible with that theme. I have the the Tainacan Support for Blocksy plugin. And exactly the same thing is happening.

Here’s one of my collections pages: William H. Roberts Collection – Moorestown Library so you can see what’s happening.

If I’m understanding correctly, the single-items.php file is what would populate the page. I’ve looked at all of the files in the tainacan folder and in the template-parts folder and can’t see where that file is called.

I can’t figure out where the problem is. Can you help?

Joanne

Hi @joannep!

Looking into your pages HTML, it seems that the code that you made earlier copying from Tainacan Interface to try to make your theme compatible is still rendering in the Item Page, thats why you don’t see any changes. Did you make a child theme of Blocksy? Because if so, then your “tainacan/single-items.php” will replace the Support plugin one. You should not need that file, you can safely remove it if your plan is to use the Blocksy+Support plugin stack.

Giving more details, the folder that renders the item page in the Support plugin is this one:

But its logic it’s no the same of a child theme as it is a plugin instead.

Let me know if removing the previous file solved your issue, ok?

Hi Mateus -

That totally fixed it. Thanks!

Out of curiosity…if I weren’t using Blocksy and the support plugin, what file would render the item page? And what would call it?

Joanne

To override or customize the Item Single page information, you would have to create a file tainacan/single-items.php, which I believe you did right. The thing is what to call there and it depends entirelly on what you are trying to build. It would be done using both WordPress and our own template tags, most of them you can find in this file.

Looking into the theme source code is a good way to give you an idea, but as they offer customization options, they usually split this file into several get_template_part calls to organize things:

A good example to start with would be something like this:

<?php get_header(); ?>

<?php if ( have_posts() ) : ?>

	<?php while ( have_posts() ) : the_post(); ?>

	<article role="article" id="post_<?php the_ID()?>" <?php post_class()?>> 

           <h1><?php the_title(); ?></h1>

           <h2>Document</h2>

           <?php
           tainacan_the_item_gallery(array(
				'layoutElements' => array( 'main' => true, 'thumbnails' => false ),
				'mediaSources' => 	array( 'document' => true, 'attachments' => false, 'metadata' => false),
			));

           tainacan_the_metadata_sections();

           ?>
           <h2>Attachments</h2>
		  <?php
           tainacan_the_item_gallery(array(
				'layoutElements' => array( 'main' => false, 'thumbnails' => true ),
				'mediaSources' => 	array( 'document' => false, 'attachments' => true, 'metadata' => false),
			));
           ?>

           <h2>Related Items</h2>
           <?php tainacan_the_related_items(); ?>

     </article>

     <?php endwhile; ?>

   <?php else : ?>
	  <p>Nothing found!</p>
   <?php endif; ?>

<?php get_footer(); ?>

Thanks! That was the piece I’ve been missing in all this. I appreciate you taking the time to help.

Joanne

1 curtida