This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Add JS popup in news editor


avatar
error 232
From: -
Add JS popup in news editor

How can I add JS popup like this:

Source | Download | View | Screen | Full story | Full review | Homepage

When I click on source or any other of above links i get popup where i enter source title and link to source. I want to add that below news editor. When i write article a i i just add source name and source link. Source name must be linkable.

Thanks

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Add JS popup in news editor
avatar
OP 232
From: -
That was it. Thanks a lot Philipp.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
Change the second code to:

    $html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 ); 

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\ntinyMCE.execInstanceCommand('input_newsstory_extendedstory', 'mceInsertContent', false, '' + option + ': ' + thistext + '')\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('Source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
Works. Thank you. Smiling Face

Just one issue. When i try to insert news source in extended news it put it in first field, in story, instead of extended news.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
Are you using the WYSIWYG editor? In this case you need to use this code:

      if( !$preferences[ 'news_wysiwyg' ] )

{
$html -> quickhtml( "" );
}

$html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 );
echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\ntinyMCE.execInstanceCommand('input_newsstory_story', 'mceInsertContent', false, '' + option + ': ' + thistext + '')\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup('Source');\">Source</a> | <a href=\"javascript:addpopup('Download');\">Download</a> | <a href=\"javascript:addpopup('View');\">View</a> | <a href=\"javascript:addpopup('Screen');\">Screen</a> | <a href=\"javascript:addpopup('Full story');\">Full story</a> | <a href=\"javascript:addpopup('Full review');\">Full review</a> | <a href=\"javascript:addpopup('Homepage');\">Homepage</a><br /><br />";


if( !$preferences[ 'news_wysiwyg' ] )
{
$html -> quickhtml( 2 );
}

$html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );
echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\ntinyMCE.execInstanceCommand('input_newsstory_story', 'mceInsertContent', false, '' + option + ': ' + thistext + '')\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('Source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
When i edit story wysiwyg doesn't work after modification.
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
yes, after modification those two files.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
Do you get this error after the modification?
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
ang got error when editing story in cadmin area:

Webpage error details


User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; AskTB5.5)
Timestamp: Sat, 1 May 2010 19:24:09 UTC


Message: Expected ';'
Line: 905
Char: 12
Code: 0
URI: http://www.******.org/cadmin/index.php?action=managestories&opts=editstory


added below codes to adminaddnewsstory.php and admineditstory.php


$html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 );
echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_story.value = window.document.getElementById(\"newform\").input_newsstory_story.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup('News source');\">Source</a> | <a href=\"javascript:addpopup('Download');\">Download</a> | <a href=\"javascript:addpopup('View');\">View</a> | <a href=\"javascript:addpopup('Screen');\">Screen</a> | <a href=\"javascript:addpopup('Full story');\">Full story</a> | <a href=\"javascript:addpopup('Full review');\">Full review</a> | <a href=\"javascript:addpopup('Homepage');\">Homepage</a><br /><br />";





if( !$preferences[ 'news_wysiwyg' ] )
{
$html -> quickhtml( 2 );
}

$html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );
echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_extendedstory.value = window.document.getElementById(\"newform\").input_newsstory_extendedstory.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('News source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
This modification should also work in 2.1.
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
You changed a lot of files and i need to redone my custom edited files again. Smiling Face
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
This is what i have now in adminaddnewsstory.php


$html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 ); 

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_story.value = window.document.getElementById(\"newform\").input_newsstory_story.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup('News source');\">Source</a> | <a href=\"javascript:addpopup('Download');\">Download</a> | <a href=\"javascript:addpopup('View');\">View</a> | <a href=\"javascript:addpopup('Screen');\">Screen</a> | <a href=\"javascript:addpopup('Full story');\">Full story</a> | <a href=\"javascript:addpopup('Full review');\">Full review</a> | <a href=\"javascript:addpopup('Homepage');\">Homepage</a><br /><br />";





if( !$preferences[ 'news_wysiwyg' ] )
{
$html -> quickhtml( 2 );
}

$html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );
echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_extendedstory.value = window.document.getElementById(\"newform\").input_newsstory_extendedstory.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('News source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
Where to change that?
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
Because TinyMCE is using a complete different syntax. The following should theoretically work:

Replace:

window.document.getElementById(\"newform\").input_newsstory_story.value = window.document.getElementById(\"newform\").input_newsstory_story.value + \"\" + option + \": \" + thistext + \"\"


with:

tinyMCE.execInstanceCommand('input_newsstory_story', 'mceInsertContent', false, '' + option + ': ' + thistext + '')


and (second one):

window.document.getElementById(\"newform\").input_newsstory_extendedstory.value = window.document.getElementById(\"newform\").input_newsstory_extendedstory.value + \"\" + option + \": \" + thistext + \"\"


with:

tinyMCE.execInstanceCommand('input_newsstory_extendedstory', 'mceInsertContent', false, '' + option + ': ' + thistext + '')
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
Philipp,

I have a problem that it doesn't work when WYGIWYS is enabled.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
I updated the code. Please try it again.
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
First one work like a charm. The other one, news_submission_form doesn't work. Link is not linkable when i enter it.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
You need to apply the same code in /cadmin/news/admineditstory.php

For the submission form change the template news_submission_form to this:

<!-- Template: news_submission_form -->

<script type="text/javascript">
<!--
function addpopup(option)
{
var thistext = prompt("Enter a description for the link","")
var thislink = prompt("Enter the link"," http://")
window.document.getElementById("submissionform").input_story.value = window.document.getElementById("submissionform").input_story.value + "" + option + ": " + thistext + ""
}
function addpopup2(option)
{
var thistext = prompt("Enter a description for the link","")
var thislink = prompt("Enter the link"," http://")
window.document.getElementById("submissionform").input_extendedstory.value = window.document.getElementById("submissionform").input_extendedstory.value + "" + option + ": " + thistext + ""
}
-->
</script>
<h1>Submit News</h1>
<div class="content">
<form action="contentteller.php" method="post" id="submissionform" enctype="multipart/form-data">
{$insert['newssubmission_anon']}
<strong>Title:</strong><br />
<input name="input_title" size="67" value="{$insert['input_title']}" /><br /><br />
{$insert['newssubmission_channels']}
<strong>Story:</strong><br />
<textarea cols="65" name="input_story" rows="10">{$insert['input_story']}</textarea><br />
<a href="https://www.contentteller.com/javascript:addpopup('Source');">Source</a> | <a href="https://www.contentteller.com/javascript:addpopup('Download');">Download</a> | <a href="https://www.contentteller.com/javascript:addpopup('View');">View</a> | <a href="https://www.contentteller.com/javascript:addpopup('Screen');">Screen</a> | <a href="https://www.contentteller.com/javascript:addpopup('Full story');">Full story</a> | <a href="https://www.contentteller.com/javascript:addpopup('Full review');">Full review</a> | <a href="https://www.contentteller.com/javascript:addpopup('Homepage');">Homepage</a><br /><br />
<strong>Extended Story:</strong><br />
<textarea cols="65" name="input_extendedstory" rows="10">{$insert['input_extendedstory']}</textarea><br />
<a href="https://www.contentteller.com/javascript:addpopup2('Source');">Source</a> | <a href="https://www.contentteller.com/javascript:addpopup2('Download');">Download</a> | <a href="https://www.contentteller.com/javascript:addpopup2('View');">View</a> | <a href="https://www.contentteller.com/javascript:addpopup2('Screen');">Screen</a> | <a href="https://www.contentteller.com/javascript:addpopup2('Full story');">Full story</a> | <a href="https://www.contentteller.com/javascript:addpopup2('Full review');">Full review</a> | <a href="https://www.contentteller.com/javascript:addpopup2('Homepage');">Homepage</a><br /><br />
<strong>Link:</strong><br />
<input name="input_link" size="67" value="{$insert['input_link']}" /><br />
{$insert['newssubmission_extra_fields']}{$insert['newssubmission_upload']}{$insert['newssubmission_securitycode']}
<input type="hidden" name="input_security_hash" value="{$insert['news_security_hash']}" />
<input type="hidden" name="faction" value="news_dosubmitstory" />
<input type="submit" name="input_dopreview" value="Preview" />
<input type="submit" value="Submit" />
</form>
</div>
<br />
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
It works now. I'm missing this on edit news and submit news too. Where do I add it.
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
Do you get any error message? Can you try it in Firefox?
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
Still doesn't work. Slightly Frowning Face
1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
I see, the code is only working in Safari Hushed Face

Try to replace the first code with:

     $html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 );

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_story.value = window.document.getElementById(\"newform\").input_newsstory_story.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup('Source');\">Source</a> | <a href=\"javascript:addpopup('Download');\">Download</a> | <a href=\"javascript:addpopup('View');\">View</a> | <a href=\"javascript:addpopup('Screen');\">Screen</a> | <a href=\"javascript:addpopup('Full story');\">Full story</a> | <a href=\"javascript:addpopup('Full review');\">Full review</a> | <a href=\"javascript:addpopup('Homepage');\">Homepage</a><br /><br />";


and the second one with:

      $html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\nwindow.document.getElementById(\"newform\").input_newsstory_extendedstory.value = window.document.getElementById(\"newform\").input_newsstory_extendedstory.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('Source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";


Let me know if this works.
1 Re: Add JS popup in news editor
avatar
OP 232
From: -
Pop up works but doesn't add link in news. When enter title and link in popup and click OK nothing happend.

JS Error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Timestamp: Fri, 27 Mar 2009 00:00:30 UTC


Message: 'input_newsstory_story' is undefined
Line: 485
Char: 1
Code: 0
URI: http://www.****.org/cms/cadmin/index.php?action=addnewstory

1 Re: Add JS popup in news editor
avatar
Editor
0
From: -
This require two code modifications in /cadmin/news/adminaddnewstory.php

Find:

      $html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 );


and replace with:

     $html -> upperform( $words_news[ 'STORY' ], "input_newsstory_story", $input_newsstory_story, 25 );

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\ninput_newsstory_story.value = input_newsstory_story.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup('Source');\">Source</a> | <a href=\"javascript:addpopup('Download');\">Download</a> | <a href=\"javascript:addpopup('View');\">View</a> | <a href=\"javascript:addpopup('Screen');\">Screen</a> | <a href=\"javascript:addpopup('Full story');\">Full story</a> | <a href=\"javascript:addpopup('Full review');\">Full review</a> | <a href=\"javascript:addpopup('Homepage');\">Homepage</a><br /><br />";


Find:

 $html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );


and replace with:

    $html -> upperform( $words_news[ 'EXTENDED_STORY' ], "input_newsstory_extendedstory", $input_newsstory_extendedstory, 25 );

echo "\n\n<script type=\"text/javascript\">\n<!--\nfunction addpopup2(option)\n{\nvar thistext = prompt(\"Enter a description for the link\",\"\")\nvar thislink = prompt(\"Enter the link\",\"http://\")\ninput_newsstory_extendedstory.value = input_newsstory_extendedstory.value + \"\" + option + \": \" + thistext + \"\"\n}\n-->\n</script>\n\n";
echo "<a href=\"javascript:addpopup2('Source');\">Source</a> | <a href=\"javascript:addpopup2('Download');\">Download</a> | <a href=\"javascript:addpopup2('View');\">View</a> | <a href=\"javascript:addpopup2('Screen');\">Screen</a> | <a href=\"javascript:addpopup2('Full story');\">Full story</a> | <a href=\"javascript:addpopup2('Full review');\">Full review</a> | <a href=\"javascript:addpopup2('Homepage');\">Homepage</a><br /><br />";

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.