Jump to content
TNG Community

How can I (if possible) pre-fill the suggest.php Subject field in a hyperlink?


JMM

Recommended Posts

Hello again, folks,

In my blurb at the top of my Cemeteries page, I have a hyperlink to suggest.php for users to submit any discrepancies that they find.  The code that I currently have for that hyperlink is:

<a href='suggest.php'  class='sidelink' target='_blank'><span style='color:blue;'><b>HERE</b></span></a>

I have seen where mod developers have a special form, where when a user is taken to those forms, the subject field is pre-populated with the name of the mod that the form is for.

Is there a way that I can include, in my above hyperlink, some additional code that would pre-populate the subject field on the suggest.php form with some text?  For example, I would like, when the user clicks on the hyperlink, for the suggest.php form to open with the Subject field pre-filled with something like Cemetery error/discrepancy/suggestion.

Is that possible, and if so, how?

Thanks in advanced.

Regards,
John

Link to comment
Share on other sites

Rob Severijns

John,

I have all my registered set as "Submitter" this allows them to skip the Suggest form and directly inform the Admin about proposed changes.

There will be a small pencil behind the subjects looking like this:

image.png

Clicking the pencil opens a popup:

image.png

After "Save changes is clicked the  Admin will recieve a notification via email and in TNG itself (Admin area)

image.png

Clicking the review link opens a new tab where you can review the suggested changes.

image.png

This works just fine for me and might work for you too.

Downside is that it doesn't work for non-registered users.

Thinking of a mod request that shows the pencil for non-registered users too but I'm not sure yet of the implications regarding the recieving of spam.

 

Link to comment
Share on other sites

Hi, Rob,

I see the way your method works, although as you mention it wouldn't work for non-registered users.  In my case, I have only 3 registered users... I don't think I have ever had more than 3 registered users in 19 years of running TNG :mrgreen:.

After I made the post, I thought that perhaps I could make a copy of suggest.php, and then in that new suggest page have the subject already filled in.

I went ahead and just tried that, so now when a user clicks on that hyperlink in the blurb at the top of my Cemeteries page, they are taken to THIS page.  I tested it, and it works.  I would've preferred to have accomplished the same thing instead simply within a hyperlink, but until then (or if that is not possible), at least this method works.

If nobody else is aware whether it is possible to include a subject within a hyperlink, I will reach out to Darrin to see if it is possible.

Thanks for taking the time to reply with how you do a similar thing on your site.

Regards,
John

Link to comment
Share on other sites

Rob Severijns

Hi John,

At least for now you have a work around.

2 hours ago, Rob Severijns said:

Thinking of a mod request that shows the pencil for non-registered users too but I'm not sure yet of the implications regarding the recieving of spam.

I will have a look at the implications regading security/spam before I request for a new mod.

All others are welcome to chime in.

Link to comment
Share on other sites

10 minutes ago, JMM said:

I would've preferred to have accomplished the same thing instead simply within a hyperlink

Just a note, when I say from within a hyperlink, what I mean is something like this (the example here of course does not work, but is shown here just to show what I mean):

<a href="suggest.php?subject='Cemetery discrepancy'" class="sidelink" target="_blank"><span style="color:blue;"><b>HERE</b></span></a>
Link to comment
Share on other sites

Ken Roy

@JMM

John,

You should not have to create your own version of suggest.php.  TNG has supported adding a subject to the suggest.php form URL since either TNG v9 or v10.  The format of the URL is  ?page= 

so in your case it would be something like

<a href="suggest.php?subject=Cemetery+discrepancy"

Edited to add TNG Wiki page reference for the Contact Us Subject Line

Link to comment
Share on other sites

Ken,

Thanks for that information.  However, it is not working for me.

But I think I have a bigger issue.  On one of my TNG 14.0.4 test sites, I have NO mods installed, and have made absolutely no modifications myself to any of the files.  When I click on Contact Us, I see this, with a subject line:

image.png

On my public site, I uninstalled the 4 mods that touch suggest.php, and I also refreshed suggest.php from my tngfiles1404.zip file, then cleared my browser's cache, and this is what see, without a subject line:

image.png

But I know what the problem must be: my template.  When I select a different template, the subject line is displayed.  It's only with my heavily-modified template 2 that the subject line does not appear.  So it would seem that when TNG v9 was introduced, whatever new line of code put that subject line in, I did not port over to my template 2's index file.  Having no idea what that line of code was, I think it's about time that I rebuild my home page from scratch, using the template 2 from TNG 14.0.4 as my base file :mrgreen:.

But thanks, Ken, for the information you have provided.  Have yourself a great day.

Regards,
John

Link to comment
Share on other sites

Hey John, a typical approach to this is to add a querystring to the hyperlink, and then use a the superglobal $_GET variable in the target page to retrieve the info from the querystring.

So a hyperlink: <a href="www.example.com?subject=mysubject">Link</a>

Can be parsed in example.com with $_GET['subject']

And the form field on example.com might look like:

<input type="text" name="page" class="longfield" value="<?php $_GET['subject']; ?>">

Cheers

 

GOGGS

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...