This topic is locked

Menu Item numbers not working

4/7/2011 3:01:44 PM
ASPRunnerPro General questions
T
Tim author

Hello,
From this blog entry I copied the following code:
--------

if menuItem.getLinkType() = "Internal" then

table=menuItem.getTable()

asp_include "include/" & GetTableURL(table) & "_settings.asp", false

table=GetOriginalTableName(table)

set rs=CustomQuery("select count(*) as c from " & AddTableWrappers(table))

menuItem.setTitle_p1(menuItem.getTitle() & " (" & rs("c") & ")")

end if
ModifyMenuItem = true

--------
and placed it in the "Menu item: Modify" event and I get this error:
-----

Microsoft VBScript runtime error '800a0411'
Name redefined

-----
Any thoughts? Should I upload to demo?

Thanks,

Tim

Sergey Kornilov admin 4/8/2011

Thanks for pointing, here is the correct code:

if menuItem.getLinkType() = "Internal" then

table=menuItem.getTable()



pagename = Request.ServerVariables("SCRIPT_NAME")
asp_include "include/" & GetTableURL(table) & "_settings.asp", true



table=GetOriginalTableName(table)

set rs=CustomQuery("select count(*) as c from " & AddTableWrappers(table))

menuItem.setTitle_p1(menuItem.getTitle() & " (" & rs("c") & ")")

end if


ModifyMenuItem = true
T
Tim author 4/11/2011

Thank you. That did the trick, but I now realize I'd like something slightly different. This code counts records in the table based on the query from the Edit SQL query page of ASPR, but I alter the where statement for many of my list pages via the events page. Can I have the menu item's count include that additional where statement? Does that make sense?
Also, this is a great trick and would make a great feature. Maybe on the misc page you could have a check box for including record count on menu item. Just a thought: it'd be handy.
Thanks as always.

Tim

Sergey Kornilov admin 4/11/2011

You can try to use session variables that store SQL, WHERE and ORDER BY for each table:

SESSION("<table name>_sql"), SESSION("<table name>_where"), SESSION("<table name>_order")
Don't have an example of doing that.

More info at http://xlinesoft.com/asprunnerpro/docs/asprunner_session_variables.htm