pluck
pluck 4.7 out now, download it today!

pluck support forums

for all your questions about the easiest CMS on the planet

You are not logged in.

Announcement

New registrations are disabled for some spam problems. New registrations will be avaliable soon. If you want to help to keep forum away from spam - contact us.
Please post your bug reports on Launchpad.

#1 08-02-2009 17:15:34

mecano
Member
Registered: 09-01-2008
Posts: 67

Sub menu for Pluck 4.6.x (with sample theme)

Modification

This will add a extra option to Pluck............a sub menu for Pluck.

Sub menu title and content can be changed dynamically by editing the page title and content in Pluck admin.
---------------------------------------------------------------------------------------

Edit 02-26-2010
new download for changes see post #2

dowload:
pluck_4.6.x_submenu

pluck_4.6.x_submenu_02-26-2010_unzip_first.zip
contents:
modified php files
pluck theme evergreen with submenu
puck-submenu.pdf

Note:
Upload the contents with your favourite FTP program to pluck
only the theme what's included can be installed trough the backend of Pluck admin

---------------------------------------------------------------------------------------

showsubmenufm5.jpg
w640.png

plucksubmenufronttp1.jpg
w640.png


The following files are modified for Pluck SubMenu

Edit these files:
index.php

data/inc/
editpage.php
functions.admin.php
newpage.php
page_editmeta.php
post_get.php

data/inc/lang/en.php

in theme.php (see also Theming guide)
add this line:

<?php theme_submenu('<li><a href="#file" title="#title">#title</a></li>'); ?>

add the function: theme_submenu in index.php

added  lines in: index.php

//[THEME] FUNCTION TO SHOW THE SUBMENU
//---------------------------------
function theme_submenu($html,$htmlactive = NULL) {
	$dir = 'data/settings/pages';
	$path = opendir($dir);
	while (false !== ($file = readdir($path))) {
   	if(($file !== ".") and ($file !== "..")) {
			if(is_file($dir."/".$file))
				$files[]=$file;
			else
				$dirs[]=$dir."/".$file;           
		}
	}
	if($files) {
		//Sort the array
		natcasesort($files);

		foreach ($files as $file) {
			if (isset($_GET['file'])) {
				$currentpage = $_GET['file'];
			}
			include('data/settings/pages/'.$file);

			//Only display in submenu if page is submenu
			if ((isset($submenu)) && ($submenu == 'yes')) {
				//Check if we need to show an active link
				if ((isset($currentpage)) && ($currentpage == $file) && ($htmlactive)) {
					$html_new = str_replace("#title", $title, $htmlactive);
					$html_new = str_replace("#file", "?file=$file", $html_new);
	   	 		echo $html_new;
				}
				else {
					$html_new = str_replace("#title", $title, $html);
					$html_new = str_replace("#file", "?file=$file", $html_new);
	    			echo $html_new;
				}
				
	    	}
		}
	}
	closedir($path);
}

changed lines in newpage.php and editpage.php 02/26/2010 improved code by a_bach

//Options div		
echo "<div style=\"background-color: #f4f4f4; width: 600px; padding: 5px; border: 1px dotted gray; margin: 5px;\">
<table>
<tr>
  <td><img src=\"data/image/options.png\" border=\"0\" alt=\"\" /></td>
  <td>
</tr>
<tr>
<td><span class=\"kop3\">$lang_contact2</span><br />";

//Display checkbox for the hidepage-option #improved Code by a_bach#
if ($hidden == 'no')
	echo "<input type=\"checkbox\" name=\"hidepage\" value=\"no\" checked> $lang_pagehide1<br />";
else
	echo "<input type=\"checkbox\" name=\"hidepage\" value=\"no\"> $lang_pagehide1<br />";

if ($submenu == 'yes')
	echo "<input type=\"checkbox\" name=\"submenupage\" value=\"yes\" checked> $lang_submenu1<br />";
else
	echo "<input type=\"checkbox\" name=\"submenupage\" value=\"yes\"> $lang_submenu1<br />";

echo "
</td>
</tr>
<td>"; 

//Display checkbox for the submenu-option
echo "
</td>
</tr>
</table>
</div>";

//Submit button
echo "<input type=\"submit\" name=\"Submit\" value=\"$lang_install13\" />
<input type=\"button\" name=\"Cancel\" value=\"$lang_install14\" onclick=\"javascript: window.location='?action=page';\" />
</form>";

//If form is posted...
if(isset($_POST['Submit'])) {

//Check if we want to show the page in the menu
if ($hidepage != "no") {
	$hidepage = "yes";
}

//Check if we want to show the page in the menu
if ($submenupage != "yes") {
	$submenupage= "no";
}

//Now we have to check which filenames are already in use 
if (file_exists("data/settings/pages/kop1.php")) {
	$i = 2;
	$o = 3;
	while ((file_exists("data/settings/pages/kop$i.php")) || (file_exists("data/settings/pages/kop$o.php"))) {
		$i = $i+1;
		$o = $o+1;
	}
	$newfile = "data/settings/pages/kop$i.php";
}
else {
	$newfile = "data/settings/pages/kop1.php";
}

$data = $newfile;
include("data/inc/page_stripslashes.php");

//Sanitize data
$kop = htmlspecialchars($kop);

$file = fopen($data, "w");
fputs($file, "<?php
\$title = \"$kop\";
\$content = \"$tekst\";
\$hidden = \"$hidepage\";
\$submenu = \"$submenupage\";");

changed lines in: functions.admin.php

//Function: save a page.
//-------------------
function save_page($name, $title, $content, $hidden = false, $submenu = false) {
	//Check if the file should be hidden.
	if ($hidden == true)
		$hidden = 'yes';
	else
		$hidden = 'no';
		
	if ($submenu == false)
		$submenu = 'no';
	else
		$submenu = 'yes';
		
	$data = 'data/settings/pages/'.$name.'.php';
	$file = fopen($data, 'w');
	$title = stripslashes($title);
	$title = str_replace('"', '\"', $title);
	$content = stripslashes($content);
	$content = str_replace('"', '\"', $content);
	fputs($file, '<?php'."\n"
	.'$title = "'.$title.'";'."\n"
	.'$content = "'.$content.'";'."\n"
	.'$hidden = "'.$hidden.'";'."\n"
	.'$submenu = "'.$submenu.'";'."\n" //**
	.'?>');
	fclose($file);
	chmod($data, 0777);
}

changed lines in: page_editmeta.php

if(isset($_POST['Submit'])) {
	$data = 'data/settings/pages/'.$editmeta.'';
	include('data/inc/page_stripslashes.php');
	  
	$file = fopen($data, 'w');
	fputs($file, '<?php'."\n"
	.'$title = "'.$title.'";'."\n"
	.'$content = "'.$content.'";'."\n"
	.'$hidden = "'.$hidden.'";'."\n"
	.'$submenu = "'.$submenu.'";'."\n");

	//Only save other variables if they are set

changed lines in: post_get.php

//POSTS
$kop = $_POST['kop'];
$tekst = $_POST['tekst'];
$back = $_POST['back']; 
$txt = $_POST['txt'];
$type = $_POST['type'];
$cont = $_POST['cont'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$chosen_lang = $_POST['chosen_lang'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
$contactform = $_POST['contactform'];
$hidepage = $_POST['hidepage'];
$submenupage = $_POST['submenupage'];
$album_name = $_POST['album_name'];
$quality = $_POST['quality'];
$incmodule = $_POST['incmodule'];
//Some variables for general use

Add new line in data/inc/lang/en.php

//VERSION 4.6 NEW
//---------------
$lang_submenu1 = "show page in submenu";

Theme:
don't  forget to style your new submenu layer in style.css

existing websides
When everything is done, go to Pluck admin --> login
go to:pages Here you can manage, edit and delete your pages

open the existing pages and save them again with your wanted preferences (show page in menu and / or show page in submenu)

when done the extra line
'$submenu = "yes"' is written to kop1.php, kop2 .php,............  etc.

for fresh installations this is not needed!



of course you can add your own translation in your language example for German you add the translation in de.php

Used editor: Notepad ++

regards mecano

Last edited by mecano (28-02-2010 14:23:43)

Offline

#2 09-02-2009 12:52:44

mecano
Member
Registered: 09-01-2008
Posts: 67

Re: Sub menu for Pluck 4.6.x (with sample theme)

pluck_4.6.x_submenu_unzip_first.zip:
--------------------------------------------------------------------------------------------------------------
contents:
modified php files
pluck theme with submenu
puck-submenu.pdf


--------------------------------------------------------------------------------------------------------------
changes:
--------------------------------------------------------------------------------------------------------------
02-26-2010 Modification by a_bach check box submenu (pluck admin) check box will stay checked when editing page.

02-24-2010 packed with zip instead tar.gz to prevent installing trough the backend of Pluck admin

02-10-2009 added pluck theme with submenu and puck-submenu.pdf

02-12-2009 Correction theme styling in readme.txt and added Polish translatioPolish translation by A_Bach

Last edited by mecano (27-02-2010 10:21:16)

Offline

#3 09-02-2009 14:26:53

Tadziz
Member
Registered: 11-01-2009
Posts: 27

Re: Sub menu for Pluck 4.6.x (with sample theme)

good job smile respect !

it dont work for me, i think i did something wrong. Maybe you can post here your changed files so we could download  smile thx

one more thing. Can you show page where we could see how it works smile

Last edited by Tadziz (09-02-2009 15:15:48)

Offline

#4 10-02-2009 20:08:16

JGMetcalfe
Member
Registered: 12-07-2008
Posts: 29

Re: Sub menu for Pluck 4.6.x (with sample theme)

ROCK 'N ROLL - Works a treat!! and its fits into my new theme perfectly.

Many Thanks - Great work

Offline

#5 11-02-2009 18:02:08

JGMetcalfe
Member
Registered: 12-07-2008
Posts: 29

Re: Sub menu for Pluck 4.6.x (with sample theme)

Is it me? - or does each page now default to "Show page in menu;" - so that if you edit a "submenu" page, you have to uncheck "Show in menu" and recheck "Show in submenu" - Not a problem now I know to check for it......... but if it is a bug, just letting you know about it. hmm

Offline

#6 12-02-2009 00:25:26

mecano
Member
Registered: 09-01-2008
Posts: 67

Re: Sub menu for Pluck 4.6.x (with sample theme)

Edit 02/26/2010

problem solved

see new download


good luck
regards mecano

Last edited by mecano (27-02-2010 10:27:25)

Offline

#7 12-02-2009 20:05:24

andyash
Member
Registered: 11-06-2008
Posts: 101

Re: Sub menu for Pluck 4.6.x (with sample theme)

Hey Mecano,

You have taken Pluck to the next level with this hard work. I tried the above coding by hand but even though everything else seemed in place the link didn't show. But replacing my files with the ones I downloaded from above set the ball rolling.

Good job.

Offline

#8 18-02-2009 09:58:05

mecano
Member
Registered: 09-01-2008
Posts: 67

Re: Sub menu for Pluck 4.6.x (with sample theme)

@ JGMetcalfe

Nice theme's you created for Pluck with sub-menu

http://www.t4p.me.uk

Your site is really a recommendation!!

THX

Last edited by mecano (23-02-2009 11:44:00)

Offline

#9 18-02-2009 19:41:24

Sander
project webmaster
From: The Netherlands
Registered: 14-06-2007
Posts: 942
Website

Re: Sub menu for Pluck 4.6.x (with sample theme)

Result looks great, mecano! I hope to find time to take a look at your code soon. Unfortunately, I don't have much time at the moment. sad

Offline

#10 26-02-2009 18:13:12

superdad
Member
Registered: 07-11-2007
Posts: 123

Re: Sub menu for Pluck 4.6.x (with sample theme)

Wow, just downloaded changes and installed. What a great addition. I wish I had that kind of expertise with php. Just bought my first book this week. I am going to update my themes this week. Thank you mecano. I really think this should be added to the current release immediately, for all to use.

Last edited by superdad (26-02-2009 18:13:47)

Offline

#11 19-07-2009 16:09:59

ragou
Member
Registered: 03-07-2009
Posts: 9

Re: Sub menu for Pluck 4.6.x (with sample theme)

Where is module_info.php?

Offline

#12 19-07-2009 20:26:25

ragou
Member
Registered: 03-07-2009
Posts: 9

Re: Sub menu for Pluck 4.6.x (with sample theme)

At last I figured out how it works. Thanks a lot.
Works fine.

Last edited by ragou (19-07-2009 20:26:46)

Offline

#13 08-08-2009 20:46:13

westial
Member
From: Barcelona
Registered: 01-07-2009
Posts: 19
Website

Re: Sub menu for Pluck 4.6.x (with sample theme)

thank's, very good big_smile
I had this error with the checkeds and I have did:

//added in line 44:
//Check if we have to check the submenu checkbox
if (($submenu == "yes") || (!$submenu)) {
    $hidecheck2 = "checked";
}
else {
    $hidecheck2 = "";
}

//changed in input checks:
//Display checkbox for the hidepage-option
echo "<input type=\"checkbox\" name=\"hidepage\" value=\"no\" $hidecheck> $lang_pagehide1;
</td>
</tr>
</td>
<td>";

//Display checkbox for the submenu-option
echo "<input type=\"checkbox\" name=\"submenupage\" value=\"yes\" $hidecheck2> $lang_submenu1<br />
</td>
</tr>
</table>
</div>";

Last edited by westial (08-08-2009 20:59:48)

Offline

#14 06-10-2009 18:52:23

Hallon
Member
From: Sweden
Registered: 05-10-2009
Posts: 24
Website

Re: Sub menu for Pluck 4.6.x (with sample theme)

Hi, new to pluck and must say i love it. Easy to configure and good description on how to make your own theme. Now to my question about the submenu.
Is it possible to have the submenu on one page only? As i get it now the submenu is on every page, i want to be able to configure it like this:

My main page
Different sodas, and on this page submenu with Coca Cola, Pepsi and so on.

Is this possible?

And btw this was just an example, not doing a site about sodas, just drank a bottle now big_smile

Offline

#15 06-10-2009 21:08:22

jellisontech
Member
From: Maine
Registered: 10-01-2009
Posts: 99

Re: Sub menu for Pluck 4.6.x (with sample theme)

Yes and no.  At least for me. 

http://pluck.ekyo.pl/en/5.Modules.php

You can download the multitheming modification and the submenu modification.  Um...  I can't seem to get it to work together though, so I use the multitheming and custom designed a page with the links.  Bad though if you change the order of the pages - you'd also have to update the custom page.  But works good for me.

Maybe someone can help you get both to work together.  I was pointed in the right direction by a_bach but I must have done something wrong because I could never get both to work together.  Anyway, do the submenu first and then follow the directions here:

http://www.pluck-cms.org/forum/viewtopi … 2639#p2639

Hopefully, it will work for you.

PS.  If anyone else reads this and gets both to work, please let me know.  smile

Offline

#16 15-10-2009 15:47:58

Eejeewee
Member
Registered: 17-02-2009
Posts: 13

Re: Sub menu for Pluck 4.6.x (with sample theme)

When I try to install the submenu module in the latest version I get the message that the module does not work with your version of Pluck. What is the solution?

Offline

#17 15-10-2009 17:58:36

a_bach
developer/module guru
From: Poland
Registered: 24-11-2008
Posts: 439
Website

Re: Sub menu for Pluck 4.6.x (with sample theme)

Eejeewee wrote:

When I try to install the submenu module in the latest version I get the message that the module does not work with your version of Pluck. What is the solution?

Submenu is not a module - is modification. Dont install it - you will have to repalce manualy some files on ftp.

Offline

#18 24-02-2010 11:20:44

mecano
Member
Registered: 09-01-2008
Posts: 67

Re: Sub menu for Pluck 4.6.x (with sample theme)

westial wrote:

thank's, very good big_smile
I had this error with the checkeds and I have did:

>......cut......<  code not quoted


Thanks for pointing at this
code is changed and available in a new download (improved code by a_bach)

greetings  mecano wink

Last edited by mecano (27-02-2010 10:15:56)

Offline

#19 13-11-2010 18:19:23

tonyp
Member
Registered: 26-10-2010
Posts: 1

Re: Sub menu for Pluck 4.6.x (with sample theme)

I have the same problem as hydex in 4.6.4.  After implementing the submenu, every page I edit gets duplicated after saving.  It is very annoying but the submenu itself works.

Last edited by tonyp (13-11-2010 18:20:02)

Offline

#20 06-12-2010 14:52:22

niobe
Member
Registered: 06-12-2010
Posts: 5

Re: Sub menu for Pluck 4.6.x (with sample theme)

hi, i would like to use this plugin as it would almost exactly fit my needs of a submenu, but when i try installin it in version 4.6.4 i cannot access anything anmore. the Browser just shows
"Access denied"
Has anyone encountered this before - and an idea on how to solve it?

Offline

#21 06-12-2010 17:59:16

rfuller
Member
Registered: 27-01-2010
Posts: 49

Re: Sub menu for Pluck 4.6.x (with sample theme)

niobe wrote:

hi, i would like to use this plugin as it would almost exactly fit my needs of a submenu, but when i try installin it in version 4.6.4 i cannot access anything anmore. the Browser just shows
"Access denied"
Has anyone encountered this before - and an idea on how to solve it?


Edit module_info.php file and change

$module_compatibility = "4.6.3";into


$module_compatibility = "4.6.4";

Copy and pasted from a reply that a_bach made in another post.

Offline

#22 07-12-2010 17:14:28

niobe
Member
Registered: 06-12-2010
Posts: 5

Re: Sub menu for Pluck 4.6.x (with sample theme)

thank you for the reply, but i think this won't work, because submenus is a modification and not a module and as such doesn't have a file called module_info.php
in the normal modules already stands:  $module_compatibility = "4.6";
I'll go ahead and look into the code, but i fear my knowledge of php is too little to find out why it is not working sad

Offline

#23 07-12-2010 18:06:41

niobe
Member
Registered: 06-12-2010
Posts: 5

Re: Sub menu for Pluck 4.6.x (with sample theme)

I think i found it smile *Argh* No i didn't! i still get another error:

"Cross-site request forgery detected."

pluck checks in all files wether a variable 'IN_PLUCK' is defined. this is to make sure the file isn't accessed directly. in all the files of the modification this check is done differently and in the modified index.php not at all.
so i  changed/allded in all the files of the modification:

defined('IN_PLUCK') or exit('Access denied!');

Now i will try finding out where the new error comes from.... any help/ideas appreciated

edit2: acutally i can add and edit pages, just get this error everytime i try to save a page.

Last edited by niobe (07-12-2010 18:13:33)

Offline

Board footer

Powered by FluxBB