Changing tag list to load content by ajax (fix #40) and updating the default sort order of backend lists (fix #49)

This commit is contained in:
Jason Williams
2020-10-28 17:56:43 -06:00
parent a50c117a98
commit 675c377d91
8 changed files with 165 additions and 133 deletions

View File

@@ -1,26 +1,32 @@
<?php namespace JasonWilliams\Feed\Components;
use Db;
use Cms\Classes\ComponentBase;
use JasonWilliams\Feed\Models\Tags;
class TagList extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'Tag List',
'description' => 'Displays a list of feed tags.'
];
}
public function defineProperties()
{
return [];
}
public function onRun()
{
$this->page['tags'] = Tags::groupBy('tag')->select(Db::raw('tag, count(*) as count'))->orderBy('count', 'desc')->get();
}
}
<?php namespace JasonWilliams\Feed\Components;
use Db;
use Cms\Classes\ComponentBase;
use JasonWilliams\Feed\Models\Tags;
class TagList extends ComponentBase
{
public function componentDetails()
{
return [
'name' => 'Tag List',
'description' => 'Displays a list of feed tags.'
];
}
public function defineProperties()
{
return [];
}
public function onRun()
{
$this->page['renderPartial'] = $this->property('tagPartial');
$this->addJs('/plugins/jasonwilliams/feed/assets/javascript/loadtaglist.js');
}
public function onAjaxDataRequested()
{
return Tags::groupBy('tag')->select(Db::raw('tag, count(*) as count'))->orderBy('count', 'desc')->get();
}
}

View File

@@ -1,5 +1 @@
<ul>
{% for tag in tags %}
<li><a href="{{ tag.tag }}">{{ tag.tag }}</a></li>
{% endfor %}
</ul>
<div id="tagcloud">Loading...</div>