Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

SQL Queries in Breadcrumb Titles

Questions related to using nuBuilder Forte.
Post Reply
ajackson
Posts: 19
Joined: Fri Mar 22, 2024 4:59 pm

SQL Queries in Breadcrumb Titles

Unread post by ajackson »

Although I can use Hash cookies in Breadcrumb titles, it seems that I'm unable to use them in SQL statements in Breadcrumb titles.
Is there a way round this?

Cheers,
Alan
Lov'in nuBuilder, keep up the good work! :D
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: SQL Queries in Breadcrumb Titles

Unread post by kev1n »

Hi Alan,

Could you share your SQL statement?
ajackson
Posts: 19
Joined: Fri Mar 22, 2024 4:59 pm

Re: SQL Queries in Breadcrumb Titles

Unread post by ajackson »

The SQL statement I'm using goes like this:

select extpatientid from Patient_v where patientid = '#PatientID#'

but this cases a fatal error.

However, if I wrap the statement in another select it does not crash and I can see on the server that the hash cookie #PatientID# is not being interpreted.

select (select extpatientid from Patient_v where patientid = '#PatientID#')

Furthermore, if I just use #PatientID# in the Breadcrumb title it is successfully parsed.

Hope this helps,
Alan
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: SQL Queries in Breadcrumb Titles

Unread post by kev1n »

In my case it also happens that the Hash Cookies don't resolve in SQL. I will investigate this further.
As a workaround, you can use the JS function nuSetTitle() to set the breadcrumb title.
Please note that extpatientid must be an object on your form (can be hidden).
Alternatively. use a display object where you can use SQL and then set the title with nuSetTitle().
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: SQL Queries in Breadcrumb Titles

Unread post by kev1n »

I believe this should fix it:
In nuform.php, replace the function nuBreadcrumbDescriptionPart() with this one:

Code: Select all

function nuBreadcrumbDescriptionPart($bt){

	$bt = nuReplaceHashVariables($bt);
	if(strtolower(substr(nuTrim($bt), 0, 6)) == 'select'){
		$t	= nuRunQuery($bt);
		return db_num_rows($t)> 0 ? db_fetch_row($t)[0] : '';
	}

	return $bt;

}
ajackson
Posts: 19
Joined: Fri Mar 22, 2024 4:59 pm

Re: SQL Queries in Breadcrumb Titles

Unread post by ajackson »

Wow, you are a champion!
Will this fix be in future releases?

I'm currently testing nuBuilder out on legacy databases to see how it can work with existing composite natural keys.
Looking good so far...if this can be achieved then I think you're on to a winner. Goodbye Access!

Cheers,
Alan
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: SQL Queries in Breadcrumb Titles

Unread post by kev1n »

Fix is on Github, thanks for testing!
Post Reply