在这里,我们将给大家分享关于dedecms获取文档当前栏目所在目录链接URL的知识,让您更了解获取当前页面标签种类的本质,同时也会涉及到如何更有效地$str=asdfasdf123541[url]as
在这里,我们将给大家分享关于dedecms 获取文档当前栏目所在目录链接 URL的知识,让您更了解获取当前页面标签种类的本质,同时也会涉及到如何更有效地$str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。、Access to XMLHttpRequest at
- dedecms 获取文档当前栏目所在目录链接 URL(获取当前页面标签种类)
- $str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
- Access to XMLHttpRequest at
from origin has been blocked by CORS policy【php】 - CodeIgniter 从 url 中删除 index.php - CodeIgniter removing index.php from url
- DEDECMS JSON数据生成 DEDECMS JSON接口制作
dedecms 获取文档当前栏目所在目录链接 URL(获取当前页面标签种类)
查了下网上有网友提供了解决的办法,贴出来大家分享:方法一:
{dede:type typeid=''0′ row=1}[field:typelink /]{/dede:type}
方法二:
动手改装一下函数了,利用 DEDECMS 自定义函数的接口文件,我们在文章页中的标记以
{dede:field.typeid function=''typeurl_arc (@me)''/} 这个放在内容页的模板中,
下把如下函数:
function typeurl_arc($typeid){
$typeurl = ";
$dsql = new DedeSql(false);
$row = $dsql ->GetOne("select typedir from dede_arctype where id=$typeid");
$typeurl = MfTypedir($row[''typedir'']);
return $typeurl;
}
放到 extend.func.php 里
注:MfTypedir 为 dedecms 系统内置函数
同样的是获取文档所在当前目录,还是第一个简单啊,呵呵,当然我想应该不是所在目录的一级目录,我想要的是这个,所以这两个方法不适合我。暂时没有找到调用所在一级目录的方法,有了后续补上。。。。
补充:dedecms 获取当前文档 url 地址的方法:{dede:field name=''arcurl''/}
$str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
[url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。
Access to XMLHttpRequest at from origin has been blocked by CORS policy【php】
1.前端报错
Access to XMLHttpRequest at ''http://localhost:8080/api/user/login'' from origin ''http://localhost:808
2.开始以为是跨域问题
已经在入口文件增加header(''Access-Control-Allow-Origin: *'');//支持全域名访问
但是仍然不行
3.原因是前端使用了框架-axios
完整的配置
header(''Pragma: no-cache'', false);
header(''Access-Control-Allow-Origin: *'');//支持全域名访问
header(''Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'');//支持的http动作
header(''Access-Control-Allow-Headers:x-requested-with,content-type'');//响应头
CodeIgniter 从 url 中删除 index.php - CodeIgniter removing index.php from url
问题:
My current urls look like this [mysite]index.php/[rest of the slug]
.我目前的网址看起来像这样[mysite]index.php/[rest of the slug]
。
I want to strip index.php
from these urls.我想从这些 url 中删除index.php
。
mod_rewrite
is enabled on my apache2 server.我的 apache2 服务器上启用了mod_rewrite
。 In config
, $config[''index_page''] = '''';
在config
, $config[''index_page''] = '''';
My codeignitor root .htaccess
file contains,我的 codeignitor 根.htaccess
文件包含,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
But still it is not working.但它仍然无法正常工作。 Where am I going wrong?我哪里错了?
解决方案:
参考: https://stackoom.com/en/question/1IUSFDEDECMS JSON数据生成 DEDECMS JSON接口制作
json数据格式可以方便不同站点之间进行数据调用引用,当然我们的DEDECMS也可以实现全站数据生成JSON供其他站点调用,代码很简单,主要用到include/json.class.php。
织梦本身是自带json标签的,调用办法:
{dede:json url='' cache=300}
[field:id/]-[field:title/]<br/>
{/dede:json}
这个标签调用例子在织梦手册里已经给我们提供了,url是一个远程json接口地址,这个接口文件json.php代码 里面,*后的返回必须是把数据通过json_encode($feeds)系统函数,进行json编码后,通过echo或print()函数来打印出来,这二点是必须的,然后,在前台我们就可以通过$.ajax()或$.getjson()来获取数据。织梦系统给我们提供了一个json类,在include/json.class.php文件里面,也就是是说,我们在对php文件转换json编码,就有了二种办法:
1.直接用php系统给我们提供的系统函数,json_encode(),我建立大家用这个,即简单又省事,既然,php系统给我们提供了,我们可以不用织梦系统提供的。
2.就是用织梦系统提供的,encode(),在使用前,首先引入json.class.php,即:
require_once(DEDEINC.'/json.class.php');
$json = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS);
echo $json->encode($reval);
$reval这个变量是我们从数据库或其它地方得到的,一般是一个二维数组,例如下:
Array (
[0] => Array ( [id] => 95 [title] => 原图设计)
[1] => Array ( [id] => 113 [title] => ssssssssssss)
[2] => Array ( [id] => 111 [title] => hjhj )
[3] => Array ( [id] => 110 [title] => ssssssssssss)
)
经echo 以后,显示的内容如下所示。
[
{"id":"95","title":"\u539f\u521b"},
{"id":"113","title":"ssssssssssss"},
{"id":"111","title":"hjhj"},
{"id":"110","title":"ssssssssssss"}
]
这是经过encode()或用json_encode()后,显示的内容。即,用中括号括起来的,几个json数据,这个数据回给请求的$.ajax()或$.getjson(),并由其对这个数据进行处理,显示我们相要的结果。
知道了原理,接下来就是详细实现办法,如下:
首先新建一个PHP文件,命名为json.php(也可以新建个文件夹命名为api,然后PHP命名为index.php,这样调用的时候就只需要你的域名/api这样的方式调用),用于作为被调用的API接口,代码如下:
<?php
$cfg_NotPrintHead = false;
header("Content-Type: text/html; charset=utf-8");
include_once (dirname(__FILE__)."/../include/common.inc.php");
error_reporting(E_ALL || ~E_NOTICE);
require_once(DEDEINC.'/json.class.php');
$reval = array();
$dsql->SetQuery("SELECT id,title FROM `dede_archives` ORDER BY id DESC LIMIT 0,10");
$dsql->Execute('me');
while ($row = $dsql->GetArray('me')) {
$row['title'] = gb2utf8($row['title']);
$reval[] = $row;
}
$json = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS);
echo $json->encode($reval);
?>
这里代码有进行了GBK转UTF8的操作,所以兼容GBK版的DEDECMS
调用办法:
{dede:json url='域名/json.php' cache=300}
[field:id/]-[field:title/]<br/>
{/dede:json}
把调用代码放到你你需要的地方就行
本文章网址:http://www.ppssdd.com/code/10237.html。转载请保留出处,谢谢合作!今天关于dedecms 获取文档当前栏目所在目录链接 URL和获取当前页面标签种类的分享就到这里,希望大家有所收获,若想了解更多关于$str =asdfasdf123541[url]asdfasdf[/url]cxgew435asdfasdf; [url]asdfasdf[/url] 想把这块去掉,最好的方法是什么。、Access to XMLHttpRequest at
本文标签: