Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 344843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:01:41+00:00 2026-05-12T11:01:41+00:00

Currently my code below works fine but it’s a bit of overkill. In my

  • 0

Currently my code below works fine but it’s a bit of overkill. In my controller I fetch the categories that have links and all the links in my database.
In my view I loop through all the categories and then when I want to add the links under the category I loop through all the links in my database instead I should only loop through the links that are assigned to the current category but I don’t know how to do this with Zend Framework. Can anybody send me into right direction. Thank’s for your time.

Controller:

    public function indexAction()
    {
        $this->view->title = App_Translate::translate('links_title');
        $this->view->headTitle($this->view->title, 'PREPEND');

        $linkCat = Doctrine_Query::create()
                    ->distinct()
                    ->from('LinkCategory lc')
                    ->innerJoin('lc.Link l WITH lc.id = l.link_category_id')
                    ->orderBy('lc.id')
                    ->execute();

        $links = Doctrine_Query::create()
                    ->from('Link')
                    ->execute();

        $this->view->linkCat = $linkCat;
        $this->view->links = $links;
    }
}

View:

   <?php if(!empty($this->linkCat)): ?>
        <ul>
            <?php foreach($this->linkCat as $linkCat): ?>
            <li><h2><?php echo $this->escape($linkCat['title']); ?></h2>
                <?php if(!empty($this->links)): ?>
                <ul>
                    <?php foreach($this->links as $link): ?>
                        <?php if($link['link_category_id'] == $linkCat['id']): ?>
                            <li><a href="<?php echo $this->escape($link['url']); ?>"><?php echo $this->escape($link['title']); ?></a></li>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </ul>
                <?php endif; ?>
            </li>
            <?php endforeach; ?>
        </ul>
    <?php else: ?>
        <p>No links added</p>
    <?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:01:42+00:00Added an answer on May 12, 2026 at 11:01 am

    Your question is not really related to Zend Framework. You are fetching data using Doctrine, not ZF.

    In your case, I think you should be able to loop over the links in the specific category using foreach($linkCat->Link as $link), seeing how you use innerJoin to load the relation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have the code below it works fine up until I actually try
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
The code below will validate required fields within currently visible fieldsets, but only if
I'm trying to learn C++ currently, but I'm having issues with the code below.
I've put together a small code-sample below (Currently in C# 3.5 but would also
I have a controller that stores various info (Ie. FormID, QuestionAnswerList, etc). Currently I
I have got a drop down menu which works fine but i want to
The code below is the code i am using. It works fine in thunderbird
I have some code that works and changes the style sheet using a form.
Im trying to generate a color gradient using ColdFusion. My current code below works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.