@pichalite said in How to delete all topics from a Category ?:
delete/purging topics from the client side does not remove the category
You are right....so I am left with a 'fake' category which I disable anyway
i want to add new topic button in may navigation bar. how can i do it?
Add an ID of 'newtopic' to a custom route, set the route to '#'
And you will need to add some js, in the custom header section.
<script>
$(function(){
$('body').on('click', '#newtopic', function () {
var cid = ajaxify.data.cid;
if (cid) {
$(window).trigger('action:composer.topic.new', {
cid: cid
});
} else {
socket.emit('categories.getCategoriesByPrivilege', 'topics:create', function(err, categories) {
if (err) {
return app.alertError(err.message);
}
categories = categories.filter(function(category) {
return !category.link && !parseInt(category.parentCid, 10);
});
if (categories.length) {
$(window).trigger('action:composer.topic.new', {
cid: categories[0].cid
});
}
});
}
});
});
</script>
That's the same function that's in app.js
Really, there should be an app.newTopic() that you can call anywhere. Then it would just be
$(function(){$('body').on('click', '#newtopic', app.newTopic);};
Could even be one of the available core routes.
This pr makes it a lot easier.