I'm sorry for asking so many questions these past few weeks but I come from a design-heavy background. And while I have been making websites for nearly 20 years, the SPA style is like learning a new language. I am trying to do something similar to the OP and am not understanding where I have made an error. Here is a simple example - the IndexPage has a navItems()
function that has a font-awesome icon I would like to replace. The original function from IndexPage.js
is as follows:
navItems() {
const items = new ItemList();
const params = this.stickyParams();
items.add(
'allDiscussions',
LinkButton.component({
href: app.route('index', params),
children: app.translator.trans('core.forum.index.all_discussions_link'),
icon: 'far fa-comments',
}),
100
);
return items;
}
My goal is to extend it, like so:
import { extend } from 'flarum/extend';
import IndexPage from 'flarum/components/IndexPage';
export default function () {
extend(IndexPage, 'navItems', function() {
console.log('extended');
// do al the same stuff afterwards, with one change
I was careful not to use the .prototype method as datitisev mentioned and I've also attempted to have extend it using the new
command like so: extend( (new IndexPage()).navItems(), function() {
– can someone please explain how to configure these lines of code so that I can replace an existing core function?