在php仪表板的文章中链接url不起作用

I have a dashboard designed in php for the client from where he is able to add new stories/articles on the main site using the tiny mce editor, just similar to a joomla article. The problem is that when a url is linked then it appends to the main site for some reason. e.g

http://example.com/"http://careers.virginmedia.com//"

I have tried every format for the url, but doesn't work. Please can someone help me with this.

The following code adds the content

function addSponsoredAd()
{
    if(isset($_POST['submit']))
    {
        $db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);

        $userID = $_SESSION['user']['userID'];

        $ID = getNextID('sponsoredAds');

        $imgTmp = $_FILES['image']['tmp_name'];

        $image = basename(strtolower(str_replace(' ', '-', $_FILES['image']['name'])));

        $info = pathinfo($_FILES['image']['name']);

        $filename = $image;

        $imageFolder = '../mediaLibrary/sponsoredAds/';

        $imageDestination = $imageFolder.$filename;

        move_uploaded_file($imgTmp, $imageDestination);

        $title = $_POST['title'];
        $description = $_POST['description'];
        $position = $_POST['position'];
        $status = $_POST['status'];
        $content = $_POST['content'];

        $parameters = array(
            'table' => 'sponsoredAds',
            'fieldsAndValues' => array(
                            'userID' => $userID,
                            'title' => $title,
                            'description' => $description,
                            'status' => $status,
                            'position' => $position,
                            'content'=> $content,
                            'dateAdded' => datetime()
                            )
        );

        $db->insert($parameters);

        if($imgTmp != '')
        {
            $parameters = array(
                'table' => 'sponsoredAds',
                'fieldsAndValues' => array(
                    'logo' => $imageDestination
                ),
            'conditions' => 'WHERE ID = "'.$ID.'"'
            );

            $db->update($parameters);
        }

        setMessage('Added a new sponsored ad: '.$title, 1);
        header('Location: '.BASE_URL.'dashboard/sponsoredAds');
    }
}

The code below displays it

function getSponsoredListings()
    {
        $db = new Connection(DB_HOST, DB_USER, DB_PASS, DB_NAME);
        $result = $db->query('
            SELECT *
            FROM sponsoredAds   
            ORDER BY position
        ');

        $items='';

        while($row = mysql_fetch_assoc($result))
        {
            $items .= '
                <div id="search-results">
                    <div class="search-result '.$class.'" id="searchResult'.$row['ID'].'">
                        <a href="sponsored-posts/'.$row['ID'].'">
                        <div class="img-container">
                            <img src="'.BASE_URL.str_replace('../', '', $row['logo']).'" alt="'.$row['title'].'" />
                        </div><!-- End img container -->
                        <h3>'.$row['title'].'</h3>
                        <p>'.$row['content'].'</p>
                        <div class="cont">'.$row['description']
                        .'</div><!-- End cont -->
                        </a>
                    </div><!-- End search result -->
                </div><!-- End search results -->
                ';
                $count++;
        }
        return $items;
    }

The tinymce page code:

<head>
    <title>Dashboard</title>
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/main.css" />
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>_style/dashboard.css" />
    <link href="<?php echo BASE_URL; ?>favicon.ico" type="image/x-icon" rel="shortcut icon" /> 
    <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>-->
    <script src="//code.jquery.com/jquery-latest.min.js"></script>
    <script src="<?php echo BASE_URL; ?>_scripts/functions.js"></script>
    <script src="<?php echo BASE_URL; ?>dashboard/_scripts/functions.js"></script>
    <script src="<?php echo BASE_URL; ?>_scripts/notify.1.0.js"></script>
    <script src="<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
    <script src="<?php echo BASE_URL; ?>_scripts/jquery.validate.min.js"></script>
    <script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
    <script src="<?php echo BASE_URL; ?>_scripts/jquery.cookie.js"></script>
    <script src="http://cdn.jquerytools.org/1.2.7/all/jquery.tools.min.js"></script>
    <script type="text/javascript">
    tinymce.init({
        selector:'textarea',
        plugins: [
            "advlist autolink lists link image charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste"
        ],
        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    });
        var BASE_URL = '<?php echo BASE_URL; ?>';
        $(document).ready(function() {

            $('textarea.tinymce').tinymce({
                // Location of TinyMCE script
                script_url : '<?php echo BASE_URL; ?>_scripts/tinymce/jscripts/tiny_mce/tiny_mce.js',

        mode : 'textareas',
        plugins : 'jbimages,paste,fullscreen,media,table',
        paste_auto_cleanup_on_paste : true,
        theme : 'advanced',
        theme_advanced_buttons1 : 'bold,italic,underline,|,bullist,numlist,|,link,unlink,image,jbimages,|,formatselect,removeformat,code, fullscreen, media,|,tablecontrols',
        theme_advanced_buttons3_add : "tablecontrols",
        table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
        table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
        table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
        table_cell_limit : 100,
        table_row_limit : 5,
        table_col_limit : 5,
        theme_advanced_buttons2 : '',
        theme_advanced_buttons3 : '',
        theme_advanced_buttons4 : '',
        theme_advanced_toolbar_location : 'top', 
        theme_advanced_toolbar_align : 'left',
        theme_advanced_resizing : true,
        theme_advanced_blockformats : 'Paragraph=p,Heading=h4,Leading=h3',
        relative_urls : false,

        valid_elements : '*[*]',
        valid_styles :  {'span' : 'text-decoration', 'img' : 'vertical-align,border,margin-top,margin-bottom,margin-left,margin-right,float'},
        width: '100%',
        height: '400',
        extended_valid_elements: "embed[width|height|name|flashvars|src|bgcolor|align|play|loop|quality|allowscriptaccess|type|pluginspage]",
        media_strict: false
    });

            $('#name').keyup(function(){
                $('#permalink').val($('#name').val().replace(/[^a-zA-Z 0-9-]+/g, '').toLowerCase().replace(/\s/g, '-').replace('--', '-'));
            });
        });
    </script>

 

<h1>Add a New Sponsored Ad</h1>

<form action="<?php addSponsoredAd(); ?>" method="post" enctype="multipart/form-data">

    <label for="image">Logo</label>
    <input type="file" name="image" id="image" />

    <label for="title">Title</label>
    <input type="text" name="title" id="title" />

    <label for="description">Description</label>
    <textarea name="description" id="description"><?php echo $info['description']; ?></textarea>

    <label for="content">Content</label>
    <textarea class="tinymce" name="content" id="content"><?php echo $info['content']; ?></textarea>

    <!-- <label for="position">Position</label>
    <input type="text" name="position" id="position" /> -->

    <label for="status"><input type="checkbox" name="status" id="status" value="1" /> Active?</label>

    <input type="submit" name="submit" id="submit" value="Add Sponsored Ad" />

</form>
doumian3780
doumian3780 是的我已经为你添加了这个
5 年多之前 回复
dongsashe6006
dongsashe6006 啊,所以你所说的是链接已经在客户端转换为错误的格式。在这种情况下,我们需要查看设置tinyMCE的前端代码。
5 年多之前 回复
doz59484
doz59484 现在来看看,基本上第一个功能只是获取信息并将其保存到数据库中,第二个是显示它,问题在于微小的mce编辑器本身,任何想法?
5 年多之前 回复
doufan1363
doufan1363 现在,您发布的代码中只有一个<a>标签,似乎这是为了链接到格式化为http://mypage.com/sponsored-ads/1234URL,所以我不认为这是你遇到问题的那个。除非你告诉我一些输出,所以我可以看到哪个链接给你带来麻烦我不认为我可以帮助你。
5 年多之前 回复
dqhmtpuy94946
dqhmtpuy94946 此代码生成一个页面,其中包含在编辑器中编写的内容,它还包含一个链接,并且该URL是外部网站,但它在我的网站链接末尾添加了外部链接,就像我上面已经解释过的那样。
5 年多之前 回复
dongxinjun3944
dongxinjun3944 哪条线产生错误的链接?你能告诉我们这段代码的一些示例输出吗?
5 年多之前 回复
doulan4939
doulan4939 嗯,我尝试过像“link.com”这样的格式“www.link.com”我也添加了代码
5 年多之前 回复
dsfds2353
dsfds2353 这是显示它的代码
5 年多之前 回复
dongping9475
dongping9475 toolong
5 年多之前 回复
dongshai1944
dongshai1944 你能告诉我们一些生成链接的代码吗?
5 年多之前 回复

1个回答



您正在使用TinyMCE和 relative_urls = false </ code>选项。 通过查看关于URL转换的TinyMCE文档,我认为您应该删除该选项并添加 convert_urls:false </ code>。</ p>
</ div>

展开原文

原文

You are using TinyMCE with the relative_urls = false option. From looking at the TinyMCE docs on URL conversion I think you should instead drop that option and add convert_urls: false.

drwjv28028
drwjv28028 对不起回复很晚,它没有工作:(尝试放弃它并添加转换网址...
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐