[PLUGIN] Contact for Bludit 2.6

User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Fri May 04, 2018 1:20 pm

Fix for the issues.

1) Add the following to plugin.php (after line 38):

Code: Select all

		$keys = array_keys($options);
		// Récupération de la valeur clé des pages				
		foreach($options as $pageKey) {
			// Création de l'objet page
			$page = buildPage($pageKey);
			// Récupération du titre de la page
			$optionsList[$pageKey] = $page->title();
			// On tri le tableau
			ksort($optionsList);
		}
2) Modify (line 57):

Code: Select all

'options'		=> $ListOptions,
instead of

Code: Select all

'options'		=> $pageOptions,
3) Modify (line 203):

Code: Select all

		if ( !$Url->notFound() &&
		     ( $Url->whereAmI()=='page' && $Page->slug()===$this->getDbField('page') )
		    )
instead of

Code: Select all

		if ( !$Url->notFound() &&
		     ( $Url->whereAmI()=='page' &&
			(($this->getDbField('page') && $Page->status()=='published') || 
			($this->getDbField('page') && $Page->status()=='static'))
		     ) )
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Fred
Legend Bludit
Posts: 304
Joined: Wed Jun 24, 2015 2:14 pm
Contact:

Fri May 04, 2018 7:02 pm

I can list the posts, but no way to load the form:
Replace this part:

Code: Select all

		// Content to display form
		HTML::formSelect(array(
			'name'			=> 'page',
			'label'			=> $Language->get('Select a content'),
			'class'			=> 'uk-width-1-3 uk-form-large',
			'options'		=> $pageOptions,
			'selected'		=> $this->getValue('page'),
			'tip'			=> '',
			'addEmptySpace'	=> false,
			'disabled' 		=> false
		));	
By:

Code: Select all

		// Content to display form
		HTML::formSelect(array(
			'name'			=> 'page',
			'label'			=> $Language->get('Select a content'),
			'class'			=> 'uk-width-1-3 uk-form-large',
			'options'		=> $options,
			'selected'		=> $this->getValue('page'),
			'tip'			=> '',
			'addEmptySpace'	=> false,
			'disabled' 		=> false
		));	
For the rest, I do not understand the problems you meet.
╰☆╮Bludit╰☆╮ is a open source and community contributions are essential to project success!
You are looking for a light forum based Json? Try my project Flatboard, it is free. ;)
Sorry for my little english, i'm french :oops:
User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Fri May 04, 2018 8:39 pm

I try to explain it with some more details.

1) Only static pages can be selected from the dropdown menu on the settings page

This is because there is the wrong value set:

Code: Select all

'options'		=> 		$pageOptions,
The list of all options is set as follows:

Code: Select all

		$pageOptions = $dbPages->getStaticDB();
		$postOptions = $dbPages->getPublishedDB();		
		$options = array_merge( $postOptions, $pageOptions );
$pageOptions shows only a list of static pages.

2) Instead of the slug of the selected page its position in the dropdown menu is saved in the database file

There is the snippet missing from for example version 2.2.1 with the value (slug) and title of the options:

Code: Select all

		$keys = array_keys($options);
		// Récupération de la valeur clé des pages				
		foreach($options as $pageKey) {
			// Création de l'objet page
			$page = buildPage($pageKey);
			// Récupération du titre de la page
			$optionsList[$pageKey] = $page->title();
			// On tri le tableau
			ksort($optionsList);
		}
Without it the value is a number and the slug is shown as title.

3) In the if conditon to determine the selected page the slug of the page is missing.

The script uses the following if condition:

Code: Select all

		if ( !$Url->notFound() &&
		     ( $Url->whereAmI()=='page' &&
			(($this->getDbField('page') && $Page->status()=='published') || 
			($this->getDbField('page') && $Page->status()=='static'))
		     ) )
The result is that the form is shown on every page.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Fred
Legend Bludit
Posts: 304
Joined: Wed Jun 24, 2015 2:14 pm
Contact:

Fri May 04, 2018 9:14 pm

╰☆╮Bludit╰☆╮ is a open source and community contributions are essential to project success!
You are looking for a light forum based Json? Try my project Flatboard, it is free. ;)
Sorry for my little english, i'm french :oops:
User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Sat May 05, 2018 12:50 am

This works. Merci beaucoup, Fred!
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Sat May 05, 2018 6:04 pm

I made a pull request with small fixes and updated German language files.

There were empty spaces after the succes and the error message. Therefore the translations didn't show.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
Fred
Legend Bludit
Posts: 304
Joined: Wed Jun 24, 2015 2:14 pm
Contact:

Sat May 05, 2018 9:24 pm

Thank Edi for your report !
First post update with new link.
╰☆╮Bludit╰☆╮ is a open source and community contributions are essential to project success!
You are looking for a light forum based Json? Try my project Flatboard, it is free. ;)
Sorry for my little english, i'm french :oops:
User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Sun May 20, 2018 2:53 pm

There is a problem, if there is only static content or only published content.

A fix could be (line 66):

Code: Select all

		// On merge le tableau
		if ( empty($postOptions) == true && empty($pageOptions) == true ) {
                    $options = array();
		}
		elseif ( empty($postOptions) == true ) {
		    $options = $pageOptions;;
		}
		elseif ( empty($pageOptions) == true ) {
		    $options = $postOptions;
		}
		else {
		    $options = array_merge( $postOptions, $pageOptions );
		}
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
LRAM
Master Bludit
Posts: 50
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Contact:

Mon Jul 09, 2018 8:37 am

Hi
thanks for this plugin , a great plus for our Bludit

any way to add the link to the menu ?
On most website, the contact link is in the navbar

Thanks
User avatar
Edi
Site Admin
Posts: 1265
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Mon Jul 09, 2018 11:56 am

The plugin adds the contact form to a selected page, and this page can be added to the navigation.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
Post Reply