Download & Extend

Hide listing links that would go to empty pages

Project:API
Version:6.x-1.x-dev
Component:User interface
Category:feature request
Priority:major
Assigned:Unassigned
Status:fixed
Issue tags:Needs tests

Issue Summary

This is what I mean by sections:

Topics
Files
Globals
Constants
Functions
API Search

Only 'files' and 'functions' actually have content when you click the links - so what is the best way to hide the empty pages like 'globals' and 'constants'?

Also the search one just leads to a page that has the same thing as the block, and I haven't bothered to write up any 'topics' so I guess those links can go too.

Comments

#1

This list of sections should be handled by the menu module allowing me to disable links and to add custom links via the menu interface.

#2

Category:support request» feature request

By default, it would be good to remove links that don't have content. This would be an additional query, something along the lines of SELECT DISTINCT object_type FROM {api_documentation} WHERE branch_name = '%s'.

I agree with moving to the menu system, but when I looked at it last, it didn't look like an easy task.

#3

Title:Show/hide different sections» Hide listing links that would go to empty pages
Priority:normal» major

I don't think we can make it be a Menu (in the sense of something you can manage via the Menu module's admin interface) very easily, because the link URLs are different for each branch. I guess we could make one menu per branch/project, but that would become excessive quickly for large installations that index multiple projects.

Hiding links when they would go to empty pages definitely seems like a good idea though. This should be done on the default branch landing page, as well as in the branch navigation block.

This should be pretty easy to do with a quick query.

#4

Status:active» needs review

Here's a patch that implements this. It appears to work, but needs tests. The test site I have is lacking globals for one branch, and this patch makes the link for globals go away in that branch. All the other links are still showing.

But I haven't tested it for other hypothetical branches that would lack topics, functions, etc. Some tests need to be devised for this.

This patch takes care of removing the empty-page links on:
- API navigation blocks
- Default branch landing page
- The Other Projects section at the bottom of listing pages and the default branch landing page

AttachmentSize
544546.patch 6.57 KB

#5

I took a sample file from #990108: Links and search do not make sense and are not working across projects comment #5, with corrections in comments #9/#10, and made a new branch/project on my testing site. This new branch has only 1 file with 1 function in it. The links that would have been made to empty pages (Globals, Topics, etc.) were correctly shown without the patch in #4 above, and were missing without the patch in #4. So I think the patch is working fine.

It still needs tests, but here's the patch in #4 with the new sample code. Note that this sample code was created to test that links would work across projects. They don't currently (see that other issue for details). So the places in the documentation of the new function that say "this should turn into a link" don't turn into links. Still, why not use the same sample code to test for two issues? :)

AttachmentSize
544546-5.patch 7.57 KB

#6

Status:needs review» reviewed & tested by the community

OK, here it is with tests. I didn't have to make any code changes to get the tests to pass, so I think this is ready to commit once we get out of beta testing mode.

AttachmentSize
544546-6.patch 15.12 KB

#7

Status:reviewed & tested by the community» fixed

This has been committed.
http://drupalcode.org/project/api.git/commit/51e1e35