Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#673 2020-02-19 13:04:28
Re: gbp_permanent_links
colak wrote #321792:
Which version of PHP? There seems to be a number of changes for each decimal.
Thanks, I have updated the previous post with full info of the 2 errors unlike what I have posted before about just one of them, running on PHP 7.0.0.
Offline
#674 2020-02-19 13:04:55
Re: gbp_permanent_links
Also, txp4.8 supports deeper url schemas such as breadcrumb/title
and section/category/title
which may make this plugin obsolete.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#675 2020-02-19 13:20:45
Re: gbp_permanent_links
colak wrote #321794:
Also, txp4.8 supports deeper url schemas such as
breadcrumb/title
andsection/category/title
which may make this plugin obsolete.
Does TXP4.8 also supports multilingual please?
I need regular URLs as section/title
and also en/section/title
where en
is just a text.
$variable[‘lang’] = ‘he’;
$variable[‘langName’] = ‘Hebrew’;$langs = array(
‘he’ => ‘Hebrew’,
‘en’ => ‘English’,
);$url = serverSet(‘REQUEST_URI’) . ‘/’;
foreach ($langs as $langKey => $langName) {
if (strstr($url, ‘/’ . $langKey . ‘/’)) {
$variable[‘lang’] = $langKey;
$variable[‘langName’] = $langName;
break;
}
}
so if this can also be done in the core on TXP 4.8 it will be great please.
Offline
#676 2020-02-19 13:39:41
Re: gbp_permanent_links
I have made a change to the code that got rid of the errors and it works, but since I’m not really know what I’m doing I would like to know your opinion if I have modified it in the right way please.
Original code:
if ($prefs['permalink_title_format']) {
$mt_search = array('/_/', '/\.html$/');
$mt_replace = array('-', '');
} else {
$mt_search = array('/(?:^|_)(.)/e', '/\.html$/');
$mt_replace = array("strtoupper('\\1')", '');
}
$mt_uri_c = $this->pref('redirect_mt_style_links')
? preg_replace($mt_search, $mt_replace, $uri_c)
: '';
Modified code:
if (isset($prefs['permalink_title_format'])) {
$mt_search = array('/_/', '/\.html$/');
} else {
$mt_search = array('/(?:^|_)(.)/', '/\.html$/');
}
$mt_uri_c = $this->pref('redirect_mt_style_links')
? preg_replace_callback(
$mt_search,
function($m){
if (isset($prefs['permalink_title_format'])) {
$mt_replace = '-';
} else {
$mt_replace = 'strtoupper($m[1])';
}
return $mt_replace;
},
$uri_c)
: '';
Last edited by THE BLUE DRAGON (2020-02-19 14:20:18)
Offline
#677 2020-02-19 13:44:28
Re: gbp_permanent_links
THE BLUE DRAGON wrote #321799:
I have made a change to the code that got rid of the errors and it works
That’s perfect! Nice work.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#678 2020-02-19 13:46:10
Re: gbp_permanent_links
You could have two sections one en
and the next one he
, and then use categories (possibly in combination of CFs) in order to achieve what you need. The section/category/title
schema actually parses urls like section-name/cat1/cat2/title
.
There was one post by etc which hints on multi-lingual options. If you dive into it and ask the questions in this forum, I’ll be following them carefully as I am also interested as to the capabilities.
Returning to deeper type urls, do check the source of the section. We will be implementing them once the next stable release comes out.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#679 2020-02-19 14:23:07
Re: gbp_permanent_links
Bloke wrote #321801:
That’s perfect! Nice work.
I hope so haha thanks.
colak wrote #321802:
You could have two sections one
en
and the next onehe
, and then use categories (possibly in combination of CFs) in order to achieve what you need. Thesection/category/title
schema actually parses urls likesection-name/cat1/cat2/title
.There was one post by etc which hints on multi-lingual options. If you dive into it and ask the questions in this forum, I’ll be following them carefully as I am also interested as to the capabilities.
Returning to deeper type urls, do check the source of the section. We will be implementing them once the next stable release comes out.
Will check all of that, thanks a lot :)
Offline
#680 2020-02-19 17:24:43
Re: gbp_permanent_links
While the front works, I do get these errors in the plugin UI page:
Fatal error: Uncaught Error: Call to undefined function select_buttons()
Fatal error: Uncaught Error: Call to undefined function event_multiedit_form()
From my understanding these are TXP core functions, how should it call them properly please?
echo n.n.tr(
tda(
select_buttons().
$this->permlinks_multiedit_form($page, $sort, $dir, $crit, $search_method)
,' colspan="4" style="text-align: right; border: none;"')
).
function permlinks_multiedit_form ($page, $sort, $dir, $crit, $search_method) {
$methods = array(
'delete' => gTxt('delete'),
);
return event_multiedit_form($this->parent->event, $methods, $page, $sort, $dir, $crit, $search_method);
}
Offline
#681 2020-02-19 17:50:47
Re: gbp_permanent_links
Also these 3 errors:
Notice “Undefined index: components”
Notice “Undefined index: settings”
Warning “extract() expects parameter 1 to be array, boolean given”
if ($id) {
// Newly saved or beening edited, either way we're editing a permlink
$step = gbp_save;
// Use the ID to grab the permlink data (components & settings)
$permlink = $this->parent->get_permlink($id);
$components = $this->phpArrayToJsArray('components', $permlink['components']);
$settings = $permlink['settings'];
} else {
// Creating a new ID and permlink.
$step = gbp_post;
$id = uniqid('');
// Set the default set of components depending on whether there is parent permlink
$components = $this->phpArrayToJsArray('components', array(
array('type' => 'section', 'prefix' => '', 'suffix' => '', 'regex' => '', 'text' => ''),
array('type' => 'category', 'prefix' => '', 'suffix' => '', 'regex' => '', 'text' => '', 'category' => '1'),
array('type' => 'title', 'prefix' => '', 'suffix' => '', 'regex' => '', 'text' => ''),
));
$settings = array(
'pl_name' => 'Untitled', 'pl_precedence' => '0',
'con_section' => '', 'con_category' => '',
'des_section' => '', 'des_category' => '', 'des_page' => '',
'des_permlink' => '', 'des_feed' => '', 'des_location' => '',
);
}
// Extract settings - this will be useful when creating the user interface
extract($settings);
Offline
#682 2020-02-21 10:57:32
Re: gbp_permanent_links
I got to a point where almost everything works fine.
There are 2 things:
1. Still no “delete” button as I have mentioned before.
2. There is some code cause links with an #
hash sign to be removed from the output.
If for example you want to create a link as <txp:site_url />#video
then it outputs it without the extension as just http://example.com/
instead of http://example.com/#video
.
Last edited by THE BLUE DRAGON (2020-02-21 11:13:01)
Offline
#683 2020-02-21 11:12:12
Re: gbp_permanent_links
OK new findings, so the hash issue is cause of the use of the function lAtts()
in the follow code:
function _pagelinkurl ($parts) {
extract(lAtts(array(
'path' => 'index.php',
'query' => '',
'fragment' => '',
), parse_url(html_entity_decode(str_replace('&', '&', $parts[2])))));
So if I just remove that lAtts()
then it seems to works fine, now I do not know what that lAtts()
function is doing and there for.
function _pagelinkurl ($parts) {
extract(array(
'path' => 'index.php',
'query' => '',
'fragment' => '',
), parse_url(html_entity_decode(str_replace('&', '&', $parts[2]))));
this seems to works, but is it OK and safe to use please?
Offline
#684 2020-02-21 11:29:10
Re: gbp_permanent_links
I do not know what that
lAtts()
function is doing and there for.
OK so the lAtts()
function is for “Adding plugin attributes”
As mentioned in TXP plugins docs :
The lAtts() function is a Textpattern function that helps you deal with tag attributes easily. It takes care of all the drudgery of making sure that users are not trying to use badly named or incorrect attribute names. It takes an array as its only argument, containing a list of all your attributes and any default values.
So…is it a mistake in the code or is it necessary to be there please?
Offline