0

We have a block containing the code:

<?php print token_replace('[current-page:url]'); ?>

which does most of what is needed, which is just to mirror the URL of a unique views page containing user-populated content. [The purpose is for sharing the user's list selections. But in this case, general "sharing" modules/functions are not appropriate and it's better to provide the URL for the user to copy into an email.]

As a useability improvement to make it easier to copy this URL, we want to generate a live-text field which has this value as its default content. What PHP code would do that?

Is is also possible to have that value (the resulting URL) automatically highlighted, so it's ready to copy? To go a step further, what would be required to add a "copy" button which would grab all of what's in the field, even if the URL is too long for full display?

  • Welcome to Drupal Answers :) Yes it's possible. Could you add in the research you've already done into the question, what you've tried, what didn't work, etc? I can understand the temptation to ask a question like this but this site isn't a code writing service; we'll gladly help with an issue you're struggling with, but we can't code your whole solution for you, no. – Clive Apr 17 '13 at 15:34
  • This seems to do most of what I was originally thinking: <input type="text" name="page_url" value="<?php print token_replace('[current-page:url]'); ?>" size=36 onclick="this.select();" /> The other improvement I was hoping to add is a "copy" button to grab all of what's in the field. In general, what kind of approach would be required for that? – Charles Apr 17 '13 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.