Favorites page button / Maybe like a wishlist

I would like to have a button on a page
-Use Case: User logs in with our SSO we get their user id, when they navigate pages they can save them to a favorites category. Then when they go to our homepage we can generate a list of urls from that and display them so they can navigate our site quicker.

  • Favorite This Page
    we will grab the user id (I know how to do this already)
    Then I check the file. - Need to read specific kirby text file - If id:page exist show red button if they don’t show blue button.
  • Then if they click the button - if it exists delete the entry if it doesn’t create it.

I hope that is simple enough. I basically need to know how to write and read from any text file anywhere on the site, store an array and call back to it. Delete it etc.

Maybe I can create a structured data page. Have 2 fields page and id.

Then once a page is saved just keep adding the ids to it like this.

32,31,50,383,594 /brandon/kirby
59,21,33,50,44,594 /kirby/rocks/yeah
etc, etc,

Then I can query the page if it exists check it’s ids. Still don’t know the best way to approach this with Kirby.

Maybe I can use tags for my user ids. Then if they “favorite” or tag that page it will ad a tag to that page. If the page doesn’t exist it will add the page and ad their user id for that page.

How many users and pages are we talking about? Maybe this would be a use case for a little data base? Of course, you could also store this in a separate content page or even in a text file (using f::write()). As an example, in my Kirby logger plugin, I save log data in a text file.

We talked about using a webservice. This could be up to 500 people per page so 500 id’s per url
Like so in structured data.


ids: 38,383,500,300, x500 potential ids
pages: page/page/kirbypage/kirbypage/etc

Since you want to show favorite pages per user, it would make sense to save a list of pages per userID rather than the other way round. In a pure Kirby environment, I’d probably store this information in the user account file. But since you are using a different login system, you have to store this information somewhere else.

So, I’ve created one template that uses modules which will be used on 90% of the pages. I’m going to ad a tag feature to that where I will store ids. Then I’ll check the array on page load for the userid.

The reason reason I’m not going to store the urls like I was, is that if a url gets changed, it will lose all it’s users and that url will need to be updated manually in the file.txt where I save the ids. Same with the logic that goes into saving it in a webservice.

Do you think in the next release. That every new page / module that is generated could have a site key id. Like sitekeyid = 1 sitekeyid = 2?

That way evertime if the user creates a new page it increments and I can track the page not by the urls but by the id. Thus if the url changes, “which happens here a lot because we use this as a backend program.” I can reference regardless if the url changes?

Currently it stores the values based on the urls. For instance, 22,55,33,55 : /about-us

But if about us changes the url to /about or in the folder structure 2-about-us becomes 3-about-us

I would have to update this manually to remind the system where the new url with user id’s was. But if Kirby auto assigned every generated page a key id. sets say about-us was keyid 3. Then

22,55,33,55 : 3

Could be stored anywhere and if the url changed it wouldn’t matter.

Then I can say query all pages for site keyid 3, show me it’s users. But if I try and query about-us and it even changed positions. Lets say from 2-about-us to 3-about-us. It will break.

Thus my logic for now will be to store all user-ids in the page under a hidden field. Then search those and see if the user that’s logged in exists.

Does this make sense? If not how can I clarify?


Do you know the AutoID plugin?

I do now :slight_smile: Thanks

I’m still wondering though, even after all this. If storing the ids in the text file will be easier. If I go that way.

How at the click of a button can I write to the current page text file from the frontend. Just wondering if there is a simple way, or a way. I read some things on post, but I would also need to remove values. Like a toggle. If it exists if it doesn’t.

Thanks for your quick reply. Support here is outstanding.

There are several plugins that might help here, for example https://github.com/jenstornell/kirby-nja

This one only increases and decreases a value, so you would have to make yours more intelligent but I hope you get the idea.