Previous pageData Integration Next page
Displaying text if records exist 

Generally when you display records from a query, you display all the records (albeit paged if there are many).

However, there are times when you want to display some text if there are some records, and display some different text if there are no records. The 'text' could be anything, including images, links, etc.

Example:

In this example we provide a link through to a page containing an embedded Query with full details of related information, but, importantly, making it so that  the link does not appear if there are no records to show.

In the following description we assume that you already have the Query that displays the records (the 'Target query'), and that is embedded on a page (the 'Target page'). We have another page (the 'Source page') that needs to contain a link to the target page, which will contain the link that should only appear if there are some records that would display on the target page. We'll also make the source page display a message that there are no records if that is the case.

To do this, we need to create a new Custom View, based on the target query. We will call this the 'Link view', and use it as shown below:

If there are records to see, then the visitor will experience the site as shown in the left column of the schematic.

Source page


Link view of Target query
(1st record of Custom View)


Click here for related records

- or -

Source page


Link view of Target query
(Custom View - No Record text)


There are no related records

|

Target page


Target query


Record 1

Record 2

...

Record n

 

 

The link view, being a Custom View, allows us to configure the "Custom View" text, and the "Custom View - No Records" text.

  • In the Custom view text, enter the text that should appear if there are any records to view
  • In the Custom View - No Records text, enter the text that should be shown if there are no record (or leave it blank if you don't want anything to show)

Now embed the 'link view' on the source page.

  • Ensure that it is set to display the correct 'link view'
  • Set it to display a maximum of 1 records. (Otherwise, the text linking to the target page will be repeated once for each record)

Note: If the source page is not a 'simple' page, but contains embedded queries displaying different content depending on the parameters it is called with, then you may want the 'link view' to include and pass forward some of the paramaters to the target page.