[PLUGIN] Contact for Bludit 2.6

User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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'))
		     ) )
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Fred
Legend Bludit
Posts: 236
Joined: Wed Jun 24, 2015 2:14 pm
Location: France
Contact:

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: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Fred
Legend Bludit
Posts: 236
Joined: Wed Jun 24, 2015 2:14 pm
Location: France
Contact:

╰☆╮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: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

This works. Merci beaucoup, Fred!
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Fred
Legend Bludit
Posts: 236
Joined: Wed Jun 24, 2015 2:14 pm
Location: France
Contact:

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: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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 );
		}
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
LRAM
Master Bludit
Posts: 199
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Has thanked: 22 times
Been thanked: 2 times
Contact:

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
https://sucrepop.com
Candies for the ears
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

The plugin adds the contact form to a selected page, and this page can be added to the navigation.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply