Trying to add a "mark read" option for individual notifications.

Michieal ~ Coder ~ Posted in Component Development 3 years ago

What am I missing here?
in the section for echoing out the notification, I am wanting to place effectively a Mark As Read icon, that a person can click or tap, to mark the individual notification as read. I'd really like to add in a delete notification so that users can delete useless notifications, such as "like comments" etc. to save on space... but...

The problem is that $params['notifications'] in the foreach statement doesn't have anything in 'guid', 'subject-guid' or 'item-guid'. How do I reference the individual notification to get the id number to pass to 'notifications/read/' or to the 'notifications/delete/' when I make the link using ossn-site-url(...)?

Thank you for your help!
-Michieal.

EDIT: replaced the _'s with -'s because it was doing weird italics.

Replies
us Michieal ~ Coder ~ Replied 3 years ago

Oh. Well... oops. lol.

@Arsalan, I made a github repository and added you to it as a contributor. Will that work?

-M.

Indonesian Arsalan Shah Replied 3 years ago

This is not my email address. Just upload the file to https://gist.github.com/

us Michieal ~ Coder ~ Replied 3 years ago

@Arsalan,

I sent it to [email protected], attn to you. I hope that works, as the ticket system kept erroring out on me.

-M.

us Michieal ~ Coder ~ Replied 3 years ago

@Arsalan,
Can I send you it, through the ticket system? Or?
-M.

Indonesian Arsalan Shah Replied 3 years ago

Cant say anything without seeing full code

us Michieal ~ Coder ~ Replied 3 years ago

@Arsalan
The following breaks the insert custom html function.
In the init() I have the register action, in the insert custom html function, I have the $link = siteurl(... , true); to make the link into an action link. (I snagged how to do it from another paid component.)
See Code:

ossn_register_action('mark/read', __MARKNOTIFICATION__ . 'actions/marknread.php');
...
$nguid = $params->guid;
$link = ossn_site_url("action/mark/read?guid={$nguid}", true);
$frag->appendXml("<a href='{$link}' ... ");

When I test it, and I use the true parameter with the ossnsiteurl(); it doesn't put in the fragment. but, if I don't use the true parameter, it shows it again, but when you click it to mark the notification, the site responds with:
"The action you requested is invalid."

So, I don't know what I am doing wrong here. Any ideas?
-Michieal.

us Michieal ~ Coder ~ Replied 3 years ago

Okay, I can see my way through this now. Wootness!

Thank you!
-M.

us Michieal ~ Coder ~ Replied 3 years ago

Have to say - rather happy here... I get a few small kinks worked out, and I will not only have this component in my arsenal, but a fully functional reply component too. :D
does a happy dance

btw - thank you so much for all of the help!

us Michieal ~ Coder ~ Replied 3 years ago

@Arsalan,
Can I ask a related question? I've tried routing the click of the url to both an action and to a page (both registered by the system) but neither want to redirect(REF); or redirect("home") properly.
Is there any issues with having a page that has code in it to do a task, but doesn't display anything, and then just redirect to either home or REF?