Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why the category_description=yes is sometimes working - sometimes not? #282

Closed
differentieel opened this issue Dec 31, 2017 · 10 comments · Fixed by #288
Closed

Why the category_description=yes is sometimes working - sometimes not? #282

differentieel opened this issue Dec 31, 2017 · 10 comments · Fixed by #288

Comments

@differentieel
Copy link

an inexplicable behaviour of the category_description tag
working:
[catlist catname=yes catname_class=h2 category_description=yes categorypage=yes template=ol order=asc excludeposts=this no_post_titles=yes thumbnail=yes force_thumbnail=yes thumbnail_size=200,200]

NOT working:
[catlist template=albumextra catname=yes catname_class=h2 excludeposts=this category_description=yes categorypage=yes order=asc no_post_titles=yes thumbnail=yes force_thumbnail=yes thumbnail_class=lcp_thumbnail]

is this normal or exceptional?
is it the order of tags: NO - - tried several combinations

if there is someone with a workaround? - much appriciated

@picandocodigo
Copy link
Owner

I think it may be related to the template being used. When you use ol, it just uses the default code with ordered tags. But with template=albumextra, you're using a custom template. Maybe if you use get_category_description somewhere in your template you can see it?

@differentieel
Copy link
Author

thank you for responding - - will try this in my template and see what happens
BTW - i have taken out the "ol" tag - i can show you why on this page: https://ferrie.audio/2017/12/max-one/ - - scroll down to the bottom and then you see the other tracks in the album

@differentieel
Copy link
Author

just tried this "code"
/* This is the string which will gather all the information.*/
$lcp_display_output = '';

// Show category link:
$lcp_display_output .= $this->get_category_link('h2');

// Show category description:
$lcp_display_output .= $this->get_category_description('<div class=".lcp_description">');

// Show the conditional title:
$lcp_display_output .= $this->get_conditional_title();

//Add 'starting' tag. Here, I'm using an unordered list (ul) as an example:
$lcp_display_output .= |<div class="flexbox-album">|;

where | = '

but that did not change anything - - this tag ".lcp_description" is in the CSS of the theme and the "flexbox-album" tags is working well

@differentieel
Copy link
Author

have done some test in a separate blogpost to find a solution but i did not succeed

Lines in the albumextra.php (only the active ones)

/**

  • The format for templates changed since version 0.17. Since this
  • code is included inside CatListDisplayer, $this refers to the
  • instance of CatListDisplayer that called this file.
    */

/* This is the string which will gather all the information.*/
$lcp_display_output = '';

// Show category link:
$lcp_display_output .= $this->get_category_link('h2');

// Show the Category Description:
$lcp_display_output .= $this->get_category_description ( |< div class = ".album-description " > | );

//Add 'starting' tag. Here, I'm using an unordered list (ul) as an example - I need a flexbox to house my covers :
$lcp_display_output .= | < div class = "flexbox-album" > | ;

global $post;
while ( have_posts() ):
the_post();

//Start a List Item for each post:
$lcp_display_output .= '';

//Post Thumbnail
$lcp_display_output .= $this-> get_thumbnail ( $post ) ;

//Close li tag - I do not use the li - so it is empty!
$lcp_display_output .= '';
endwhile;

// Close the wrapper opened at the beginning:
$lcp_display_output .= ' ' ;

$this->lcp_output = $lcp_display_output;

end of albumextra.php where | = '

Now we have 2 lcp tag-lines in the blogpost https://theme.ferrie.audio/2016/10/ontferm-u/

first lcp-tag-line after LINKS
[catlist template=albumextra category_description=yes excludeposts=this]

When the template is called the category_description is not shown - the flexbox is not correct formatted - will fix that later

second lcp-tag-line is without the template:
[catlist catname=yes catlink_class=h2 category_description=yes no_post_titles=yes excludeposts=this categorypage=yes order=asc thumbnail=yes force_thumbnail=yes thumbnail_class=lcp_thumbnail]

When the template is NOT used the category_description is shown - the flexbox is not formatted as expected - it is not called correctly

Conclusion
It seems that the OUTPUT of the template is different then the tag-line without - but now the basic(default) CSS tags are active - which makes it very difficult to design your own way of presenting the lcp-category-posts
The conflict seems somewhere in the CatListDisplayer but i am unable to find out where exactly the bug is - i am no coder - sorry for that

I hope that you guys are able to investigate this conflict to make the output more easy to design

@klemens-st
Copy link
Collaborator

Hi @differentieel

I had a look at the issue you describe and your code examples. There are a couple things I noticed:

  • The correct way to use template functions is $this->function_name(html_tag, html_class);, for instatnce $this->get_content('div', 'class-for-my-div');. What you tried to do: get_category_description (< div class = ".album-description " > ); would never work, however
  • You are right, the get_category_description function doesn't work in templates. The way it is written makes it impossible to work in templates, you could try $this->catlist->get_category_description(); but then you cannot pass tags or classes for customization, the good news is
  • I noticed all this some time ago and submitted a PR (Refactor CatListDisplayer, add some tests #288 ) that reorganizes and simplifies all templating functions, so if this is merged your problem will be solved 😉

@differentieel
Copy link
Author

thank you @zymeth25 Klemens for your explanation - i will have some more patience
about your first remark: i will correct the notation and see what happen
let's hope fore a quick treatment of (#288 )

@differentieel
Copy link
Author

Connected to this issue I ask you to look at the following difference in notation when it comes to the template:
// we have to start somewhere - that's fine
$lcp_display_output = '';

// Show category link:
$lcp_display_output .= $this->get_category_link('strong');

// Show the conditional title - or something else:
$lcp_display_output .= $this->get_conditional_title('div', 'class-for-my-div');

//Add 'starting' tag. Here, I'm using an unordered list (ul) as an example: - a flexbox offers more possibilities - why not let the user choose which way to go in the LCP-Admin-Page
$lcp_display_output .= '<ul class="lcp_catlist">';
// so this is fairly different notation from the $this-> construction - as Klemens explained above

maybe it is possible to construct the template method as a part of the LCP-Admin-Page - and then switch between [catlist name1=thing name2=thing] and [catlist = template=mytemplate] - so they do not interact with each other?

more about the flexbox

@klemens-st
Copy link
Collaborator

why not let the user choose which way to go in the LCP-Admin-Page

Yes, there is another issue (#177) where this is discussed. Hopefully in time we can develop the admin page options.

so this is fairly different notation from the $this-> construction - as Klemens explained above

Yes, of course. After $lcp_display_output .= you can write any string and it will be added to the output. The $this-> is used to call methods of the CatListDisplayer object. So if you want to use flexbox you can just write <div class="flex"> and then define the class in your CSS file. Just don't forget to close the <div> later in your template 😉

maybe it is possible to construct the template method as a part of the LCP-Admin-Page - and then switch between [catlist name1=thing name2=thing] and [catlist = template=mytemplate] - so they do not interact with each other?

Again, I agree, the more options are allowed to be customized in the admin page the better. As soon as one of the contributors has the time to code it it will be included!

@differentieel
Copy link
Author

thank you Klemens

@klemens-st
Copy link
Collaborator

You're welcome 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants