Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2024-10-04 14:44:08
- Adams
- Plugin Author
- Registered: 2024-08-30
- Posts: 38
global messages for all users
I have a need to have global manageable messages for all users when they login. Is there a plugin like this?
I need to be able to add, delete, or change more than one message and show them on login in the messages tab/section.
BTW: I tried adi_notes, but this is not what I’m looking for.
Thank you
Offline
Re: global messages for all users
Do you mean when they log into the admin side? Or into some front-of-house website area?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#3 2024-10-04 17:41:35
- Adams
- Plugin Author
- Registered: 2024-08-30
- Posts: 38
Re: global messages for all users
Not the front end (front-of-house), only when users login into the back end (like authors). same as adi_notes, but with multi messages and viewable on a single tab, it doesn’t matter where.
I don’t want to reinvent the wheel; if there is a plugin ready to use, that will be good; otherwise, I have to write my own.
Thank you all.
Offline
Re: global messages for all users
Okay, cool. Well you don’t necessarily need a dedicated plugin, as such. You could harness the power of Textpattern forms (EDIT: or, better, hidden articles. See post by etc below first, which will allow you to skip steps 2 and 3 of the Forms configuration nonsense. Then write your messages in Articles instead, and tweak the query to grab them from your chosen hidden Section and output the Body_html field).
The general idea is this:
- Download and install smd_tabber.
- Go to your Admin>Prefs [Admin] panel and make sure Advanced options is enabled.
- Visit Admin>Prefs [Advanced options] and add a new custom form template type like this:
[messages]
title=“Messages” - Define a new Presentation>Pages template called tabber_announce with the template (PHP) code shown below in it.
- Visit Admin>Manage Tabs and create a new tab called Announcements. Assign it to (e.g.) ‘start’ – or wherever you want it to appear in the menus (even the top level if you wish). Make sure you give privileges to as many user groups as you want to be able to see it. Select ‘announce’ as the Page template to use.
Once all that’s set up, in your Presentation>Forms panel you can add Forms of type ‘Messages’. Give them a name and then type in your message content. You can use Textile if you like:
In Form 'running':
h2. Important announcement
Don't run with scissors.
In Form 'second-one':
h2. This week is Textpattern awareness week
Join us for lots of events and Textpattern appreciation activities.
And so on. You can go nuts with this approach. Put links, images, headings, lists, you name it.
- If you want to add a message, just create a new Form of type ‘Messages’.
- If you want to change a message at any time, just edit its Form content.
- If you want to ‘delete’ one you can either remove it entirely or just move it out of the Messages type.
- If you want to control the order they are displayed, you could use a naming convention like prefixing the form names with an alphabetic character and tweak the query in the page template code below to
order by name
. - If you create a Presentation>Styles sheet called ‘tabber_announce’ you can then assign that to your tab and style your message panel to taste.
Here’s the basic Page template code:
<txp:php>
$rs = safe_rows('*', 'txp_form', "type='messages'");
$textile = Txp::get('\Netcarver\Textile\Parser');
foreach ($rs as $row) {
echo $textile->parse($row['Form']);
}
</txp:php>
Note that I did try to use parse('<txp:output_form form="'.$row['name'].'" escape="tidy, textile" />')
but it kept returning: No form data found, for some reason. I even tried adding the skin
to extract, but it refused to work (probably because the tag needs something from the public-side code that’s not present on the admin-side).
Anyway, tweak as you see fit. It’s kind of ‘messages lite’ but it might fit the bill.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: global messages for all users
Bloke wrote #337944:
I did try to use
parse('<txp:output_form form="'.$row['name'].'" escape="tidy, textile" />')
but it kept returning: No form data found, for some reason. I even tried adding theskin
to extract, but it refused to work (probably because the tag needs something from the public-side code that’s not present on the admin-side).
I guess it needs the correct global $skin
to be set, but can not test: on install the plugin gives me
Uncaught mysqli_sql_exception: Table 'dbname.smd_tabber' doesn't exist
Anyway, might a pageless section articles be an alternative to forms? They are easier to sort, expire etc.
Offline
Re: global messages for all users
etc wrote #337945:
Uncaught mysqli_sql_exception: Table 'dbname.smd_tabber' doesn't exist...
It doesn’t auto install the tables unfortunately. You have to go to the plugin tab or Prefs or something and hit the button to do it. And I’ve no idea if it works in php 8.
Anyway, might a pageless section articles be an alternative to forms?
Absolutely. There are many ways to set it up, and articles avoid the overhead of creating a form type. Plus, expiry is a big draw for time-sensitive notices. I didn’t consider a pageless section and got blinkered going down the Forms route.
It’s a cinch to replace the query in the page template to grab articles instead of forms.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#7 2024-10-08 12:14:48
- Adams
- Plugin Author
- Registered: 2024-08-30
- Posts: 38
Re: global messages for all users
Thank you
Offline
Pages: 1