Textpattern hack : notepad

09 November 2004 @ really damn late | Comments (10)

*Update* 27 Mar 2005 -› This feature is now available as a plugin (>1.0RC3)

NOTE -› Modifications are for 1.0RC1 & 1.0RC2 (_but should still work on older versions with slight line number differences_). This hack/extension will add a ‘Notepad’ top-level tab to your admin interface and two subtabs (public/private). Every user — regardless of permissions level — has access to edit/view the public notepad. Each user also respectively has their own individual private notepad.

After some discussion on the Textpattern forum regarding the need for a notepad in the Textpattern admin interface, I decided to get a-hackin’.

Notepad TXP hack

  • Notepad (parent tab)
    • Public (subtab, all users)
    • Private (subtab, user-specific)

Currently the status of this hack is tentative. Most likely there are improvements that can be made, mainly with the database table structure and its corresponding queries.

What’s Needed

There are 4 simple steps (_in order from easiest to hardest_):

  • Upload:
    • /textpattern/include/txp_notepublic.php (download)
    • /textpattern/include/txp_noteprivate.php (download)
  • Edits(1): /textpattern/lang/en-gb.txt
  • Edits(4): /textpattern/lib/txplib_head.php
  • Add a table to your TXP database (txp_note_setup.php OR txp_note.sql)

Getting Started

Download txp_notepublic.php & txp_noteprivate.php and place the file in /textpattern/include/ with all the other txp_xxxx.php files. No other modification is needed for this step.

ADD (3 lines) /textpattern/lang/en-gb.txt -> line#347

  1. tab_notepad => notepad
  2. tab_notepublic => public
  3. tab_noteprivate => private

ADD (1 line) /textpattern/lib/txplib_head.php -> line#19

  1. $ntabs = array('notepublic','noteprivate');

ADD (1 line) /textpattern/lib/txplib_head.php -> line#23

  1. elseif(in_array($event,$ntabs)) { $area = 'note'; }

ADD (1 line) /textpattern/lib/txplib_head.php -> line#70

  1. areatab(gTxt('tab_notepad'), 'notepad', 'notepublic', $area),

ADD (4 lines) /textpattern/lib/txplib_head.php -> line#143

  1. $areas['note'] = array(
  2. gTxt('tab_notepublic') => 'notepublic',
  3. gTxt('tab_noteprivate') => 'noteprivate'
  4. );

Download diff

Database

The final step involves adding the table txp_note to your database. This can be done one of two ways. You can either load the table directly into mySQL via the SQL dump txp_note.sql, or you can place the file txp_note_setup.php in your Textpattern directory and load it via your web browser (_the latter method is still a bit awkward because there is no confirmation screen to tell you if it’s worked_).

If any part of this is unclear, please leave notes in the comments or in the TXP forum. This modification may seem daunting at first, but I assure you it’s not all that hard. With SVN it’s even easier.


10 comments

1

hurray hurray hurray and thank you thank you. :)

alicson → ferrydust.com
2

You are most welcome :-)

andrew → compooter.org/
3

Works well, thanks.

Rick → parkling.net
4

finally got some time to install this ~ worked like a charm, thanks so much.

andrea → mellowtrouble.net
5

the updated files with the save-over protection are brilliant. thanks :)

alicson → ferrydust.com
6

works perfect, thanks!

julian → julianwichmann.de
7

Great work, thanks a lot.

Jérémie → shadowfrance.net
8

ok i have done everything so far, and it has been a breeze! i am having trouble with adding the part to the database (im not very comfortable with database changes) i tried to do the set up file (txp_note_setup.php) i even changed the chmod to allpossible, it is in my main textpattern file /public_html/textpattern, i keep being told it is a file not found. it is there i have checked, refreshed, cleared cache, checked spelling,... im not sure how to make this work now or what else you need to know from me to help me… if you have a moment to email me that would be great thank you!

storm

storm → internalstorms.com
9

Hi there,

I am fairly new to TextPattern and just trying to set up some plugins/mods etc that look like they will help run my site. Your notepad idea looks great and I started to make the changes, but I am not sure I should proceed.

Do the changes in the files apply to the latest version of TextPattern, namely 1.0rc3, as I do not want to make a hash of things just yet.

Thanks for any advice you may have. The php files look simple and the database too – it’s the alterations to the existing files that concerns me most.

Thanks again

Shadow → perspectives.os42.com

Comments are closed for this article.

Previously

Elsewhere