Posted in site documentation
14
1:15 am, June 11, 2021

change this to a list group - other items

Other item format is a bit average, list group should fix this. 

This uses the template:

core-list-item-simple.html 

So we can change this a bit to the list group format. 

Which is basically this layout

HTML

<ul class="list-group">
  <li class="list-group-item">An item</li>
  <li class="list-group-item">A second item</li>
  <li class="list-group-item">A third item</li>
  <li class="list-group-item">A fourth item</li>
  <li class="list-group-item">And a fifth one</li>
</ul>

as i want it to be links, need to use the same classes and links instead. 

HTML

<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action active" aria-current="true">
    The current link item
  </a>
  <a href="#" class="list-group-item list-group-item-action">A second link item</a>
  <a href="#" class="list-group-item list-group-item-action">A third link item</a>
  <a href="#" class="list-group-item list-group-item-action">A fourth link item</a>
  <a href="#" class="list-group-item list-group-item-action disabled" tabindex="-1" aria-disabled="true">A disabled link item</a>
</div>

Changed templates to use the list-group.html and list-group-item.html rather than the core templates. 

HTML - list-group-item.html

<a href="/view/[@class_name]/[@uid]/[@title_uid]/" class="list-group-item list-group-item-action" title='[@title]'>[@title]</a

HTML - list-group-card.html

a list group inside a card to make it neater. 

<div class='card mb-3'>
  <h5 class='card-header'>[@title]</h5>
  <div class='card-body'>
    <div class="list-group">
      [@content]
    </div>
  </div>
</div>

Updated quite easily once i found the function. 

Now it looks something like this: 

Which is quite a lot nicer than the simple links and also better for mobile as you can press anywhere on the element, and makes it a bit more like buttons. 

PHP

if($class->category > " ") {
	$other_items_list_title = "Other Items in $class->category";
	$other_items_list = $class->list_all(
        $start = 0,
        $max = 50,
        $list_type = "category",
        $template_file = "list-group-item.html",
        $search_term = $class->category
      );

		$other_items_card_template = new template("list-group-card.html");
		$other_items_card_template->set("title", $other_items_list_title);
		$other_items_card_template->set("content", $other_items_list);
		$page_content .= $other_items_card_template->output();
}

View Statistics
This Week
19
This Month
83
This Year
0

No Items Found.

Add Comment
Type in a Nick Name here
 
Related Search Terms
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

Join me on Substack if you want me to send you a collection of the things i have done or found or read for the week. Or follow me on twitter if you prefer, i dont post much but i probably should!

❤👩‍💻🕹

Random Quote

"Olivia, my eldest daughter, caught measles when she was seven years old. As the illness took its usual course I can remember reading to her often in bed and not feeling particularly alarmed about it. Then one morning, when she was well on the road to recovery, I was sitting on her bed showing her how to fashion little animals out of coloured pipe-cleaners, and when it came to her turn to make one herself, I noticed that her fingers and her mind were not working together and she couldn’t do anything. 'Are you feeling all right?' I asked her. 'I feel all sleepy,' she said. In an hour, she was unconscious. In twelve hours she was dead. The measles had turned into a terrible thing called measles encephalitis and there was nothing the doctors could do to save her. That was...in 1962, but even now, if a child with measles happens to develop the same deadly reaction from measles as Olivia did, there would still be nothing the doctors could do to help her. On the other hand, there is today something that parents can do to make sure that this sort of tragedy does not happen to a child of theirs. They can insist that their child is immunised against measles. ...I dedicated two of my books to Olivia, the first was ‘James and the Giant Peach’. That was when she was still alive. The second was ‘The BFG’, dedicated to her memory after she had died from measles. You will see her name at the beginning of each of these books. And I know how happy she would be if only she could know that her death had helped to save a good deal of illness and death among other children."

I just checked google books for BFG, and the dedication is there. 

https://www.google.com.au/books/edition/_/quybcXrFhCIC?hl=en&gbpv=1 


Roald Dahl, 1986