Jump to content

probably easy solved problem with list-menu?


perik

Recommended Posts

Hi!

 

Im using a forum that is called e107 which is build in php.

Im editing this plugin:

http://plugins.keal.me.uk/plugins/recipe_menu/recipes.php

 

and run into a problem.

In the "Select Category" (see picture below) I succeded to list all the posts from a single author instead of categories by editing this code:

           $recipemenu_selcat = '
		<select class="tbox" name="recipemenu_select" onchange="this.form.submit()">
			<option value="" >' . RCPEMENU_111 . '</option>';
            if ($sql->db_Select('recipemenu_category', '*', ' order by recipe_category_name', 'nowhere', false))
            {
                while ($recipemenu_row = $sql->db_Fetch())
                {
                    extract($recipemenu_row);
                    $recipemenu_selcat .= "<option value='{$recipe_category_id}' ";
                    if ($recipe_category_id == $recipemenu_recipecat)
                    {
                        $recipemenu_selcat .= ' selected="selected"';
                        $recipe_catdesc = $recipe_category_description;
                        $recipemenu_catname = $recipe_category_name;
                        $recipemenu_where = "recipe_category='$recipemenu_recipecat'";
                        if ($recipemenu_row['recipe_category_icon'] && file_exists('images/caticons/' . $recipemenu_row['recipe_category_icon']))
                        {
                            $recipemenu_caticon = '<img src="images/caticons/' . $recipemenu_row['recipe_category_icon'] . '" style="border:0;" alt="" />';
                        }
                    }
                    $recipemenu_selcat .= '>' . $tp->toFORM($recipe_category_name) . '</option>';
                } // while
            }
            else
            {
                $recipemenu_selcat .= '<option value="0">' . RCPEMENU_4 . '</option>';
            }
            $recipemenu_selcat .= '</select>';

into:

// START CODE
            $recipemenu_selcat = '
		<select class="tbox" name="recipemenu_select" onchange="this.form.submit()">
			<option value="" >' . RCPEMENU_111 . '</option>';
            if ($sql->db_Select('recipemenu_recipes', '*', ' order by recipe_author', 'nowhere', false))
            {
                while ($recipemenu_row = $sql->db_Fetch())
                {
                    extract($recipemenu_row);
                    $recipemenu_selcat .= "<option value='{$recipe_author}' ";
                    if ($recipe_author == $recipemenu_recipecat)
                    {
                        $recipemenu_selcat .= ' selected="selected"';
                        $recipe_catdesc = $recipe_author_description;
                        $recipemenu_catname = $recipe_author;
                        $recipemenu_where = "recipe_author='$recipemenu_recipecat'";
                        if ($recipemenu_row['recipe_author_icon'] && file_exists('images/caticons/' . $recipemenu_row['recipe_author_icon']))
                        {
                            $recipemenu_caticon = '<img src="images/caticons/' . $recipemenu_row['recipe_author_icon'] . '" style="border:0;" alt="" />';
                        }
                    }
				$recipemenu_bortmedborjan = explode(".", $recipemenu_row['recipe_author'], 2);
				$recipemenu_lank = $tp->toFORM($recipemenu_bortmedborjan[1], false);
                    $recipemenu_selcat .= '>' . $recipemenu_lank . '</option>';
                } // while
            }
            else
            {
                $projectmenu_selcat .= '<option value="0">' . RCPEMENU_4 . '</option>';
            }
            $projectmenu_selcat .= '</select>';
// END CODE   

 

what i basically did was to replace the recipe_category with recipe_author.

 

The function works but the problem is that now I get a list that looks like this:

hej2.jpg

 

as you can see the authors are repeating eachother. I just want the different authors to be displayed once.

 

I was thinking to solve it by count the project_author in the project_author and if they where more than 1 i just displayed one but since im not very good in php I run into problems. This is what I tried anyway:

$text = "";
$count_project_author = $sql->db_Count("projectmenu_projects", "*", "project_author", ?????);
if($count_project_author > 1)
echo $text;

 

I know that would never work and the echo text and everything is not the right way but maybe if someone want to help to dig a bit deeper into this?

 

Heres a picture from the database from phpmyadmin:

hej1.jpg

 

thanks a lot! any help what so ever would be very much apreciated!!!

Link to comment
Share on other sites

solved it by changing:

    if ($sql->db_Select('projectmenu_projects', '*', ' order by project_author', 'nowhere', false))

to:

            if ($sql->db_Select('projectmenu_projects', 'project_author', ' GROUP BY project_author', 'nowhere', false))

The whole code is now:

//FROM
            $projectmenu_selcat = '
		<select class="tbox" name="projectmenu_select" onchange="this.form.submit()">
			<option value="" >' . RCPEMENU_111 . '</option>';
//              if ($sql->db_Select('projectmenu_projects', '*', ' order by project_author', 'nowhere', false))
            
            if ($sql->db_Select('projectmenu_projects', 'project_author', ' GROUP BY project_author', 'nowhere', false))
            {
                while ($projectmenu_row = $sql->db_Fetch())
                {
                    extract($projectmenu_row);
                    $projectmenu_selcat .= "<option value='{$project_author}' ";
                    if ($project_author == $projectmenu_projectcat)
                    {
                        $projectmenu_selcat .= ' selected="selected"';
                        $projectmenu_catname = $project_author;
                        $projectmenu_where = "project_author='$projectmenu_projectcat'";
//            	if ($projectmenu_row['project_author_icon'] && file_exists('images/caticons/' . $projectmenu_row['project_author_icon']))
//            	{
//            	$projectmenu_caticon = '<img src="images/caticons/' . $projectmenu_row['project_author_icon'] . '" style="border:0;" alt="" />';
//          	}
                    }
				$projectmenu_bortmedborjan = explode(".", $projectmenu_row['project_author'], 2);
//					$projectmenu_lank = $tp->toFORM($projectmenu_bortmedborjan[1], false);
                    $projectmenu_selcat .= '>' . $tp->toFORM($projectmenu_bortmedborjan[1], false) . '</option>';
                } // while
            }
// TO

 

But now I would like to change so I get links instead of <option> menu so it displays like below:

Katapult <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>

Per <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>

User3 <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>

User4 <a href LINK THAT LISTS ALL THE PROJECTS OF THAT USER>

and so on ...

 

so links instead of the users that are displayed in option menu "Show by member:":

hej3.jpg

 

any tips how?

 

By the way in the picture of the phpmyadmin there have been some small namechangnings so just imagine that everywhere it says project there shall be recipe instead.

 

Thanks a lot!

 

Per

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.