pagebreak / read more

Post Reply
User avatar
TA2Web
Ssr. Bludit
Posts: 13
Joined: Fri Sep 06, 2024 9:20 pm
Location: America
Has thanked: 1 time
Contact:

Hello, I seem to have trouble with the getting to use the read more link in my posts. When I try to add the pagebreak to get the read more link it goes to all white page with 'page not found'.

I edit the post to add the pagebreak and when I hit save it goes to page not found.

Any solution or am I doing something wrong within my templating? Here is the post I want to add the 'Read More' button on: Bludit: A Light CMS for Simple Web Blogging
arfa
Master Bludit
Posts: 74
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 5 times
Been thanked: 10 times

I haven't used this alot but here are a few thoughts:

In the bludit docs:
https://docs.bludit.com/en/content/add-a-read-more-link
you just add a page break

Code: Select all

<!-- pagebreak -->
(need to be in code mode to do this).

This auto creates a link at that point on your page but... just on the home/blog-post page. When you load the page directly that break has no effect.

There are two pagination plugins; one paid the other free.

I am relatively new to bludit and am just exploring building plugins and perhaps a 'readMore' plugin could be added to the list. I have some js code tucked away (somewhere) but still getting my head around the bludit-way. I will have a look and perhaps just post the code here?

BTW... nice review. Well written and upbeat. Perhaps it will inspire more savvy dudes here to chip in on this?
User avatar
TA2Web
Ssr. Bludit
Posts: 13
Joined: Fri Sep 06, 2024 9:20 pm
Location: America
Has thanked: 1 time
Contact:

Thank you for your reply.

I am aware that when you apply the pagebreak or Read More button that it only applies on the blog pages but not on the post page. Which being its intended purpose.

However when I do apply the page break or Read more Button using the blog post editor, when I save the update it goes to a page not found error.

The same happens when I try to use the youtube embed plugin.

I appreciate any help to try and get these things fixed. Thank you.
arfa
Master Bludit
Posts: 74
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 5 times
Been thanked: 10 times

Does this [page not found] only occur when you have set a pagebreak in the editor and then save? And tube plugin.
And that when you normally edit a page and save that it works fine?

There could be many things causing this. I tend to be a bit ?impulsive as I work and change things here and there and not testing enough. Incremental corruptions :( -
I have learned - and very easy to do with bludit - that going back to the beginning and adding elements to isolate the error. Basically - fresh install and add then test, etc.
I have just quickly used the editor 'page break' and it is fine - as one would expect it to be.

I would suggest that you have made some changes 'some where' and it is causing conflict. The fix I figure is unlikely to be found here with such general symptoms. Sorry not to be more specific.

ak
User avatar
TA2Web
Ssr. Bludit
Posts: 13
Joined: Fri Sep 06, 2024 9:20 pm
Location: America
Has thanked: 1 time
Contact:

Thanks for your reply. Yes I tried again today to embed a video and it seems to work now. I think the post editor is touch when it comes to pasting text content into it and then hitting save. It sometimes shows a page not found white screen.

When I still try to add a page break using the editor option it still goes to blank white page with page not found. :( .. I really would like to have the read more button on posts.

This is the code being used on the home.php:

Code: Select all

<?php foreach ($content as $page) : ?>
  <!-- Post -->
  <div class="card my-5 border-0">

    <!-- Load Bludit Plugins: Page Begin -->
    <?php Theme::plugins('pageBegin'); ?>

    <div class="card-body p-0">
      <!-- Blog Post Title -->
	  <h2 class="display-6 mb-1 fs-1"><a class="link-opacity-75-hover text-decoration-none" href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a></h2>

      <!-- Blog Post Date -->
      <div class="card-subtitle ms-1 mb-4 text-secondary small"><?php echo $page->date(); ?></div>

    <!-- Cover image -->
    <?php if ($page->coverImage()) : ?>
      <img class="card-img-top mb-3 rounded-2" title="<?php echo $page->title(); ?>" alt="<?php echo $page->title(); ?> Cover Image" src="<?php echo $page->coverImage(); ?>"/>
    <?php endif ?>

      <!-- Breaked content -->
      <?php echo $page->contentBreak(); ?>

      <!-- "Read more" button -->
      <?php if ($page->readMore()) : ?>
        <a href="<?php echo $page->permalink(); ?>"><?php echo $L->get('Read more'); ?></a>
      <?php endif ?>

    </div>

    <!-- Load Bludit Plugins: Page End -->
    <?php Theme::plugins('pageEnd'); ?>

  </div>
  <hr>
<?php endforeach ?>
I haven't made any edits outside the theme's template files. Other than one before installation to rename the admin and subfolder of the bludit blog.
arfa
Master Bludit
Posts: 74
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 5 times
Been thanked: 10 times

The code you post seems normal enough.
Did you know that it generates a link that takes you to the actual post?
I really would like to have the read more button on posts.
The built in bludit read more doesn't do this.

I found my old code and have tweaked it to fit bludit. I have built this as a plugin and now need to work out how to get it into the official repository. This is my first plugin release so... fingers crossed. ! It seems I have to host the file so I have uploaded it and you can get a copy here:
https://bodhinyanarama.net.nz/temp/read ... r-less.zip
It is a whacking 3kb so, needless to say, no real bells or whistles. I did rework my old tinyMCE code to fit for bludit and you can have a go at adding auto-tag buttons. There are suggestions in the admin plugin 'settings' page.

This doesn't solve your white-page problem but hopefully gives you a toggle button on your post page.

onward... kusalo
User avatar
TA2Web
Ssr. Bludit
Posts: 13
Joined: Fri Sep 06, 2024 9:20 pm
Location: America
Has thanked: 1 time
Contact:

arfa wrote: Wed Oct 02, 2024 1:29 am The code you post seems normal enough.
Did you know that it generates a link that takes you to the actual post?
I really would like to have the read more button on posts.
The built in bludit read more doesn't do this.
Yes, I would like to use the 'contentBreak' so that it would insert a link going to the permalink.

This code that seems to be for that purpose doesn't seem to work. There seems to be two parts of the code.

Code: Select all

      <!-- Breaked content -->
      <?php echo $page->contentBreak(); ?>

      <!-- "Read more" button -->
      <?php if ($page->readMore()) : ?>
        <a href="<?php echo $page->permalink(); ?>"><?php echo $L->get('Read more'); ?></a>
      <?php endif ?>
      
In the post editor you are supposed to be able to click the option to insert the page break where desired. OR I think you can manually add other code to insert the read more link?
You can do the same thing in the Markdown editor by adding the tag <!-- pagebreak -->.

Code: Select all

This is the first part of the content of the page.

<!-- pagebreak -->

This is the second part of the page.
Docs to Add a read more link
arfa
Master Bludit
Posts: 74
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 5 times
Been thanked: 10 times

again

Code: Select all

I really would like to have the read more button on posts.
I may be wrong but the --pagebreak-- is only intended for the homepage.
The link you set has "...will be visible on the homepage"

I also had a thought about the 'white page' you were getting. Bludit has regular "or die" set and one wrong comma, one unclosed bracket in the code and... white page - or 'page not found.' I am sure I saw (somewhere) a setting or a plugin that enabled php errors. Are you reading the browser console?

Did you have a look at my plugin - link in previous post.
It works on both home and post/page.
User avatar
TA2Web
Ssr. Bludit
Posts: 13
Joined: Fri Sep 06, 2024 9:20 pm
Location: America
Has thanked: 1 time
Contact:

I am using a modified BlogX theme which includes BootStrap 5.3

The page break / add link to permalink area of the code is found on two of the templates:

index.php:

Code: Select all

<body>
<?php Theme::plugins('siteBodyBegin'); ?>

<?php include(THEME_DIR_PHP.'navbar.php'); ?>

<!-- Start Blog Area -->
<main class="container pt-5 pt-md-4 pt-lg-3">
		<div class="row g-5">

			<!-- Blog Posts -->
			<div class="col-md-8">
			<!--<h1 class="display-6 pb-4 mb-3 fst-italic border-bottom text-center">/ blog / ..</h1>-->
			<?php
				// if you order the content by date pages works as posts
				// $WHERE_AM_I variable detect where the user is browsing
				// If the user is watching a particular page/post the variable takes the value "page"
				// If the user is watching the frontpage the variable takes the value "home"
				if ($WHERE_AM_I == 'page') {
					include(THEME_DIR_PHP.'page.php');
				} else {
					include(THEME_DIR_PHP.'home.php');
				}
			?>
			</div>
			<!-- End Blog Posts -->

			<!-- Start Sidebar -->
			<div class="col-md-4">
			<div class="position-sticky">
			<?php include(THEME_DIR_PHP.'sidebar.php'); ?>
			</div>
			</div>
			<!-- End Sidebar -->

		</div>
</main>
<!-- End Blog Area -->

<!-- Start Footer -->
<?php include(THEME_DIR_PHP.'footer.php'); ?>
<!-- End Footer -->

<!-- Load Bludit Plugins: Site Body End -->
<?php Theme::plugins('siteBodyEnd'); ?>

</body>
home.php:

Code: Select all

<?php if (empty($content)) : ?>
  <div class="mt-4">
    <?php $language->p('No pages found') ?>
  </div>
<?php endif ?>

<?php foreach ($content as $page) : ?>
  <!-- Post -->
  <div class="card my-5 border-0">

    <!-- Load Bludit Plugins: Page Begin -->
    <?php Theme::plugins('pageBegin'); ?>

    <div class="card-body p-0">
      <!-- Blog Post Title -->
	  <h2 class="display-6 mb-1 fs-1"><a class="link-opacity-75-hover text-decoration-none" href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a></h2>

      <!-- Blog Post Date -->
      <div class="card-subtitle ms-1 mb-4 text-secondary small">Posted <?php echo $page->date(); ?> by <?php echo $page->user('nickname'); ?> in <a class="text-secondary" href="<?php echo $page->categoryPermalink(); ?>"><?php echo $page->category(); ?></a></div>

    <!-- Cover image -->
    <?php if ($page->coverImage()) : ?>
      <img class="card-img-top mb-3 rounded-2" title="<?php echo $page->title(); ?>" alt="<?php echo $page->title(); ?> Cover Image" src="<?php echo $page->coverImage(); ?>"/>
    <?php endif ?>

      <!-- Breaked content -->
      <?php echo $page->contentBreak(); ?>

      <!-- "Read more" button -->
      <?php if ($page->readMore()) : ?>
        <a href="<?php echo $page->permalink(); ?>"><?php echo $L->get('Read more'); ?></a>
      <?php endif ?>

    </div>

    <!-- Load Bludit Plugins: Page End -->
    <?php Theme::plugins('pageEnd'); ?>

  </div>
  <hr>
<?php endforeach ?>

<!-- Pagination -->
<?php if (Paginator::numberOfPages() > 1) : ?>
  <nav class="paginator">
    <ul class="pagination flex-wrap">

      <!-- Previous button -->
      <?php if (Paginator::showPrev()) : ?>
        <li class="page-item mr-2">
          <a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1">&#9664; <?php echo $L->get('Previous'); ?></a>
        </li>
      <?php endif; ?>

      <!-- Home button -->
      <li class="page-item <?php if (Paginator::currentPage() == 1) echo 'disabled' ?>">
        <a class="page-link" href="<?php echo Theme::siteUrl() ?>">Home</a>
      </li>

      <!-- Next button -->
      <?php if (Paginator::showNext()) : ?>
        <li class="page-item ml-2">
          <a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $L->get('Next'); ?> &#9658;</a>
        </li>
      <?php endif; ?>

    </ul>
  </nav>
<?php endif ?>
page.php:

Code: Select all

<!-- Blog Page -->
<div class="card my-5 border-0">

	<!-- Load Bludit Plugins: Page Begin -->
	<?php Theme::plugins('pageBegin'); ?>

	<div class="card-body p-0">
		<!-- Blog Page Title -->
		<h1 class="display-6 link-body-emphasis mb-1 fs-1"><?php echo $page->title(); ?></h1>

		<?php if (!$page->isStatic() && !$url->notFound()): ?>
		<!-- Blog Post Date -->
		<div class="card-subtitle ms-1 mb-4 text-secondary small">Posted <?php echo $page->date(); ?> by <?php echo $page->user('nickname'); ?> in <a class="text-secondary" href="<?php echo $page->categoryPermalink(); ?>"><?php echo $page->category(); ?></a></div>
		
		<?php endif ?>

	<!-- Cover image -->
	<?php if ($page->coverImage()): ?>
	<img class="card-img-top mb-3 rounded-2" title="<?php echo $page->title(); ?>" alt="<?php echo $page->title(); ?> Cover Image" src="<?php echo $page->coverImage(); ?>"/>
	<?php endif ?>

		<!-- Full content -->
		<?php echo $page->content(); ?>
	</div>

	<!-- Load Bludit Plugins: Page End -->
	<?php Theme::plugins('pageEnd'); ?>

</div>
The insert function to place the 'Read More' link is only meant for the index and home page files.
arfa
Master Bludit
Posts: 74
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 5 times
Been thanked: 10 times

Hey TA2Web. Persistence will surely win - in the end. But I think we have two issues running here.
1 - your OP
Here is the post I want to add the 'Read More' button on: Bludit: A Light CMS for Simple Web Blogging
Am I correct in that you want to be able to have a 'readMore' on your post- on that page as an independent, not as a part of the home page-collection? This, for blogx, is for page.php

So, for your OP I have written a plugin that will give you a readMore (on both home and page) - and it was nice for me to do that as a part of my learning curve so thanks for that lead in !

2 - The home permalink
You clearly see that the std. 'readmore' is for the home.php only.
I am now thinking to extend the plugin to include that as an option. Just a matter of adding:

Code: Select all

if (HTML_PATH_ROOT == $_SERVER["REQUEST_URI"]) {$pageBase = 'home';}
else { $pageBase = 'page';}
and setting the link.

But... the question still remains - have you managed to solve the 'white page' blip when you set the 'pageBreadk' and save?

I don't have time to tweak the plugin just now but will post when I do. It would be nice if you tried it.

go well - kusalo
Post Reply