e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
319 stars 213 forks source link

problem with book template and pages listing on book page. #4402

Closed Jimmi08 closed 2 years ago

Jimmi08 commented 3 years ago

Question

What are you confused or uncertain about? book/chapters templating started to behave the weird way

What are you trying to accomplish?

I have a chapter with a new template (new template key). The chapter page is correct and everything works.

$CHAPTER_TEMPLATE['chapterpage']['listPages']['caption']                = "{CHAPTER_NAME}";
$CHAPTER_TEMPLATE['chapterpage']['listPages']['start']      = '<div  >';
$CHAPTER_TEMPLATE['chapterpage']['listPages']['item']                   = '<h3 id="{CPAGEANCHOR}" >{CPAGETITLE}</h3>
<div class="content">{CPAGEBODY}</div>';
$CHAPTER_TEMPLATE['chapterpage']['listPages']['end']                    = "</div>"; 

But this template is used on the book page too for shortcodes {PAGES}.
It shouldn't work this way (by looking at the code) - You set the default template key for book/chapter in preferences - in my case "default"

On the book page that template is used:

$CHAPTER_TEMPLATE['default']['listChapters']['caption']             = "{BOOK_NAME}";    
$CHAPTER_TEMPLATE['default']['listChapters']['start']               = "<ul class='page-chapters-list'>";
$CHAPTER_TEMPLATE['default']['listChapters']['item']                = "<li><h4><a href='{CHAPTER_URL}'>{CHAPTER_NAME}</a></h4>{PAGES}";
$CHAPTER_TEMPLATE['default']['listChapters']['end']                 = "</ul>";

Still correct

And for {PAGES} should be used "default" too. We are on the book with template "default".

So how it should work? If I am correct, it is a bug, if not, you can have just one template for chapters, nothing more.

CaMer0n commented 3 years ago

@Jimmi08 Thank you. I want to be sure we're talking about the same thing. If I understand well, you're referring to the 'listing' page, which utilizes 3 templates.

ie. http://localhost/e107v2/page/ with List pages if no page selected enabled in the prefs.

Here's my test case. I created an 'other' key and added descriptions (eg. (default/listChapters)) so we can see where they are used:

$CHAPTER_TEMPLATE['default']['listPages']['caption']                = "{CHAPTER_NAME} ";
$CHAPTER_TEMPLATE['default']['listPages']['start']                  = "(default/listPages) {CHAPTER_BREADCRUMB}<ul class='page-pages-list'>";
$CHAPTER_TEMPLATE['default']['listPages']['item']                   = "<li><a href='{CPAGEURL}'>{CPAGETITLE}</a></li>";
$CHAPTER_TEMPLATE['default']['listPages']['end']                    = "</ul>";  

$CHAPTER_TEMPLATE['default']['listChapters']['caption']             = "{BOOK_NAME} ";
$CHAPTER_TEMPLATE['default']['listChapters']['start']               = "(default/listChapters)<ul class='page-chapters-list'>";
$CHAPTER_TEMPLATE['default']['listChapters']['item']                = "<li><h4><a href='{CHAPTER_URL}'>{CHAPTER_NAME}</a></h4>{PAGES}";
$CHAPTER_TEMPLATE['default']['listChapters']['end']                 = "</ul>";

$CHAPTER_TEMPLATE['default']['listBooks']['start']                  = "(default/listBooks)<ul class='page-books-list'>";
$CHAPTER_TEMPLATE['default']['listBooks']['item']                   = "<li><h3><a href='{BOOK_URL}'>{BOOK_NAME}</a></h3>{CHAPTERS}";
$CHAPTER_TEMPLATE['default']['listBooks']['end']                    = "</ul>";

$CHAPTER_TEMPLATE['other']['listPages']['caption']              = "{CHAPTER_NAME} ";
$CHAPTER_TEMPLATE['other']['listPages']['start']                    = "(other/listPages) {CHAPTER_BREADCRUMB}<ul class='page-pages-list'>";
$CHAPTER_TEMPLATE['other']['listPages']['item']                     = "<li><a href='{CPAGEURL}'>{CPAGETITLE}</a></li>";
$CHAPTER_TEMPLATE['other']['listPages']['end']                  = "</ul>";  

$CHAPTER_TEMPLATE['other']['listChapters']['caption']               = "{BOOK_NAME} ";
$CHAPTER_TEMPLATE['other']['listChapters']['start']             = "(other/listChapters)<ul class='page-chapters-list'>";
$CHAPTER_TEMPLATE['other']['listChapters']['item']              = "<li><h4><a href='{CHAPTER_URL}'>{CHAPTER_NAME}</a></h4>{PAGES}";
$CHAPTER_TEMPLATE['other']['listChapters']['end']                   = "</ul>";

$CHAPTER_TEMPLATE['other']['listBooks']['start']                    = "(other/listBooks)<ul class='page-books-list'>";
$CHAPTER_TEMPLATE['other']['listBooks']['item']                 = "<li><h3><a href='{BOOK_URL}'>{BOOK_NAME}</a></h3>{CHAPTERS}";
$CHAPTER_TEMPLATE['other']['listBooks']['end']                  = "</ul>";

Result with List Books/Chapters Template set to "Default":

image

Result with List Books/Chapters Template set to "Other":

image

This is the intended behavior. Does that cover your concern or is there an issue occurring with these templates appearing on a different page?

Jimmi08 commented 3 years ago

Your $CHAPTER_TEMPLATE['default']['listPages']['item'] = "<li><a href='{CPAGEURL}'>{CPAGETITLE}</a></li>"; and $CHAPTER_TEMPLATE['other']['listPages']['item'] = "<li><a href='{CPAGEURL}'>{CPAGETITLE}</a></li>"; are the same, how do you know that wrong is used?

On book page should be used: $CHAPTER_TEMPLATE['default']['listPages']['item']

On chapter page should be used this one: `$CHAPTER_TEMPLATE['other']['listPages']['item']

And because they are the same, I can't see the difference.

Settings is: image

And only one chapter should have the template other.

image

This is like chapter looks: So template is complete different: image

But book with default template looks: image

And it should like defaut way: just ul/li,. not page content, just page list image

CaMer0n commented 3 years ago

I'm going to try to chart out a representation of how the templates work with the database at this time. Please let me know if it is behaving differently for you.

When there is no query (ie. no book, chapter or page) selected, these templates are used:

$CHAPTER_TEMPLATE[X]['listBooks'] $CHAPTER_TEMPLATE[X]['listChapters'] $CHAPTER_TEMPLATE[X]['listPages']

Where X is the List Books/Chapters Template value defined in admin > Pages/Menus > Options

When there is a book or chapter selected, the template used will vary.

In the example below, we have configured the books/chapters as follows and set the template styling accordingly:

Templates:

chapter_template.zip

Nothing Selected. (page.php)

image

Book View (page.php?bk=1)

image

Chapter View (page.php?ch=2)

image

Chapter View (page.php?ch=3)

image

@Moc @realmontazeri for dev documentation.

Jimmi08 commented 3 years ago

@CaMer0n Really thank you that you found time for this and you confirmed the same thing I found. In my opinion it is non correct.

You are saying that:

$CHAPTER_TEMPLATE[X]['listPages'] is always the same on book and on chapter page.

My opinion: if you set "default" template for book, only default template (for all content) should be used on book page. (book, chapters, pages)

If you set "panel" template for chapter, then this template should be used on chapter page for chapter and pages.

If you want your book have look like on your second image, you should add template "panel" for book, not book using chapter template.

You could disagree, but if your way is correct, then chapter_menu.php is useless.

You style your chapter_menu.php for "panel" template. But if you do this, you change look of your book too. And because you can't have chapter without book, there will be always book with bad look...

image

I was able to found workaround about this, so I don't need you to change this. I still couldn't get why people use only one book on all site, when you can separate content easily too more areas. Now I know why.

CaMer0n commented 3 years ago

@Jimmi08 I believe the problem is because chapter_menu has a hard-coded use of 'panel'. If anything should be hard-coded it should be a new key "menu". Maybe you can test with that?

Jimmi08 commented 3 years ago

It is useless, you can use any template (as a parameter), if one chapter can be displayed in the menu and listed in the book too, the result will be the same.

CaMer0n commented 3 years ago

@Jimmi08 Maybe you should just use the page_navigation_menu ?

Jimmi08 commented 3 years ago

@CaMer0n it would be a workaround too. I solved this so if you don't see the problem in that system, I will not press on it.

Book: https://www.e107sk.com/admin-area/

Chapter of that book: https://www.e107sk.com/admin-area/e107-admin-users

It is not finished, I don't have time for it now, but templates work correctly.

You can close this if you want.

Jimmi08 commented 2 years ago

My last cents on this topic.

B/CH/Pages should replace the old content plugin. If you remember correctly, there was by default Articles, Reviews, and else something. And you could add your own main categories. Those "areas/books" could look totally different

Those main categories should have been book now, correct?

And their subcategories are now chapters, correct?

So why is that in the content plugin I can set the template for all book's tree? but the different template for displaying of subcategory itself?

It should work this way: In listing

If you display the page itself, it uses a key from the page.