Trouble with the blog tutorial – getting the URL of an object

Totally new here. Hi.

I started educating myself about the workings of Elgg so I installed it and after completing (and rewriting) the hello world tutorial, I moved on to the blog tutorial. That too is kind of outdated (so I’m planning on rewriting it too!), but I could figure out most things. However, now I’ve hit a snag.

As far as I know, I’ve created all the necessary files with the code taken from the tutorial, and they seem to work; I can add a new blog post, the blog posts are saved and they show up fine if I for example list all the blog posts or list all things that have a certain tag. I have the 2.1.1 release version of Elgg.

Here are the files (yeah, I changed the suggested name “my_blog” to “journal”):









I believe this part is what’s causing the issue:

Every object in Elgg has a built-in URL automatically [...] The getURL() method is called to get that unique URL.

If I call for the URL, I get the top level address of the Elgg site I’m running. So I guess the built-in URL isn’t being generated? I also have a feeling I need a page for actually viewing a singular blog post...

Am I doing something wrong or is some fundamental part of the tutorial missing?

  • There was a generic 'view' function in Elgg, but this was removed.

    So you need to add it yourself

    if you want to get the correct url for your object register for 'entity:url' hook see Return something like journal/view/<guid>/<friendly title>

    In you page_handler catch /view and make a resource /journal/view.php. Do your displaying in this resource view (see blog for an example)

  • Thanks!

    Since the guide recommended overriding the getUrl() method, I decided to do it that way. (I first thought I shouldn’t...) Anyway, I got it to work and it was pretty easy to look at the blog plugin’s code for how it could be done. Or at least I assume that the blog plugin overrides the method. The wording isn’t very clear on that.

    I’ll work on rewriting the blog tutorial so that it’ll be up to date.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking