Share and save

Share/Save

Random piece of content

answered question

How to fix "Access Denied" for visitors?

Just as I earlier had a problem with admins unable to access a Drupal site, I had a problem with visitors unable to access a new site. That is, I could see everything fine as admin, but checking from another (non-logged-in) browser, only the default "Welcome to Drupal" content would show up. (Blocks were visible, but links to nodes in those blocks wouldn't reveal anything. In short, visitors could not access any node.)

Click here and read more!
Question answer: 

Once again, the forums to the rescue. Here's the thread that helped:

http://drupal.org/node/134505

And the comment with the solution that worked for me:

http://drupal.org/node/134505#comment-219661

I went to phpMyAdmin, called up my site database, and ran the indicated SQL query. Shazam, things worked!

I'll have to leave explanation to the pros; this is the kind of wizardry that still rings esoteric to my ears. But it did the trick, and I am grateful to solution poster briandelicata, as well as everyone posting in the thread. Great stuff!

(Oh, and one note: Before playing with your database per this solution, be sure to BACK UP THE DATABASE!)

More notes 

Here's a claim that the taxonomy_access module can cause the problem too: http://drupal.org/node/239951 

How to change a node's type?

Hide your eyes, conservatives: it's a node-change operation, the shocking switch from Blog Entry to Page, or Story to Review, whatever your desires demand. Call it a miracle or call it a travesty, modern Drupal science makes it possible... and seductively easy.

Question answer: 

I'll answer this question as quickly as I ask it – because I just tested it out while moving Drupally questions of various breed into a single node type on this site, the node type called "Drupal Questions" I created for my Question Bank. (It's a nice CCK-created node type with fields for the question, for the answer if available, and for a related URL.)

I had an old blog entry on a certain Drupal puzzle, and thought that node should be reworked into a Drupal Question. I was prepared to simply copy its content into a brand new node. But lo, that blog entry had a couple of comments, and I'd hate to lose those. How would I also move the comments from the old node to the new node I'd be creating? I dunno.

Hmm, a better idea: instead of making a new node, how about transforming the old blog entry node into a new type? I seemed to recall a module claiming that transfigurational wherewithal...

And here it is: Nodetype. http://drupal.org/project/nodetype

I downloaded the module and, before touching anything else, backed up my site database! That done, I installed Nodetype. It offers no admin options, and only shows up when you edit a node: you see a simple drop-down list of node types into which you can change the current node (complete with nice warning to only change the node type if you "know what you are doing"!)

In my case, I selected my custom node type "Drupal Questions" from the list. Doing a Preview of the node showed no changes, but hitting Submit put the change into effect. It worked great, and – the thing I was most hoping for – left the node's comments attached and intact. Nodetype, you swinging switch-hitter, you're all right by me!

You can see my results here:

http://www.drupalace.com/blog_entry_trick_bin_hiding_node_title_2007_07_03

That node was a Blog Entry but is no longer; only its URL alias hints at its original configuration. (Kind of like the Adam's apple on "Lucy" in that Phuket night clu... no, the Ace is speaking too much here. Full stop.)

Now, I haven't used Nodetype enough to give out any handy tips, but the following safety procedures would seem wise:

1) Back up your database before dabbling in node DNA like this.

2) Your target node type may have different fields from your original node type, and I would imagine that data gets lost when a field gets dropped. Copy all major text field data from your original node before changing its type, to avoid loss.

3) Experiment first with a dummy node, if you really want to be safe before operating on the real thing.


If you've ever agonized over what node type to use for some piece of content, worried about getting "stuck with" the wrong decision, you can relax a bit with Nodetype in your arsenal. Bring out the tranny in your nodes! Good stuff.

How to fix "Access Denied" message locking out admins?

Yikes! A client's site suddenly turned up "Access Denied" for admins – up, down, and all around. Attempts to log in as almighty User ID 1 would simply spit the login screen right back again, or appear to "take" momentarily, yet return "Access Denied" for any following admin action.

Some horrible flub-up with user permissions? Can't even check and troubleshoot when the site won't let the admin in! And playing with cache, cookies, and other browser fiddly bits wasn't doing the job.

Question answer: 

I expected major pain to result. But a search of the Drupal site quickly turned up this gem:

http://drupal.org/node/6696#comment-198054

Just a little addition to my INDEX.PHP file. I tried it, and Huzzah! Back in logged-in action.

The cause of the problem? Perhaps this:

http://drupal.org/node/6696#comment-204960

Hmm, could it be that the ISP had updated PHP from 4 to 5? Yes, it seemed so! (Maybe now I'll start to pay attention to their newsletters.)

So the thread addressed my woe, and I'm a happy Drupaller all over again. Now, this particular case had a Drupal 4.x site knocked out of action by a PHP upgrade, so it may not apply directly to many users' situations. But if you're getting "Access Denied" hate (on 4.x or 5.x), give the linked thread a peek.

My thanks to everyone offering help on the topic, especially Drupal Gods kweisblatt and johnchalekson!

How to display date and time?

How does one display the current date and time on a Drupal site?

Question answer: 

Time for this newbie to take the plunge, and touch... oh, sweet mother of mercy... touch PHP!

A Drupal.org forum visitor asked about displaying the date and time on a site. I know there are countless ways to do this using web technologies, including any number of "widgets" available out there. For all I know, there may be a Drupal module that tosses up a block or something, too.

But I know this is the sort of task one can also do easily using PHP, the real guts of Drupal (well, part of the guts, anyway... maybe the pancreas). And it should be easy, too. So as a farewell to my... ahem... chastity with regards to PHP, let me take this oh-so-newbie challenge upon myself.

Google turns up all kinds of stuff. Like this couldn't-be-more-basic, one-size solution: http://www.totallyphp.co.uk/code/display_date_and_time_with_php.htm

Besides some code comments, there's just one line of key code there:

<?php  echo date("l, F d, Y h:i" ,time()); ?>

Let's try! I make a new block... turn off rich-text input (TinyMCE)... select PHP as my input format... and paste in the code. I save the block and make it display... and there it is, to the left! Stupendous!

Now, that's the barest of starts; I'll add more to this page as I play with more formatting and other options. (Like time zones: that's pretty important!) But wow, I'm now PHP-experienced and it didn't hurt at all. Before long I'll be up for CSS/HTML/PHP themeing three-ways til the break of dawn. Mmm, break out the mango love butter.

How to encourage readers to share content?

I am creating a new site whose topic will encourage readers to "share" specific pages' content with other people, by means such as:

* forwarding the page content to others
* pasting the page content into email (or into other sites' forums, comments, etc.)
* pasting the page URL into email (or into other sites' forums, comments, etc.)

I'll also encourage readers to leave comments on pages.

That's all nothing special so far, and nothing that a reader can't do from any generic Drupal page.

Click here and read more!
Question answer: 

I've only got a start at answers, and would love to see more ideas. Interactivity is what many sites are all about; how to implement interactive features in Drupal is no mean question for us developers!

My desired interactive links, in order:

1. "Forward this page" link

For now, I'm cheating. I have a "share content" block appear on pages of the node type which I want users to share. In that block, I have a "forward this page" item which links to #forward-form . That's simply the anchor link to the "forward this page" form provided by the Forward module; a user click, and jumps down the page to the form (which he might otherwise not immediately see, if the page is long).

It's not the same as a link that jumps to a "forward this page" form on a new page, but it works for now.

2. Copy this page's content (for pasting elsewhere)

No go. A little research shows there are solutions that work for some browsers, but I see no universal solution. Further, the business of tinkering with users' clipboards touches on security issues; wiser users may purposely block such tricks by web sites. I think I'll give up on this.

3. Copy this page's URL (for pasting elsewhere)

Same as above.

4. Add a comment

Similar to 1) above, I've simply added a link to the comments section's anchor at the bottom of the page, which is #comments . The user clicks, and jumps down the page to the comment input form. Good enough.

 

So. There are some cheap'n'quick means for making "interactivity" links more readily accessible to users via a block that gathers them together. I'd love to hear more ideas on this topic!

 

Syndicate content

Drupal power!

Powered by Drupal, an open source content management system

Drupal mini tip

You've logged out as admin, and realize there's no login block on your site... You're locked out! It's the #1 newbie emergency, with daily pleas for help appearing on the drupal.org forums!

Relax; getting back in is simple. The path <your domain>/user will always provide you a login form. (Make that <your domain>/?q=user if you don't have "clean URLs" enabled.) You're back in action.