187 Posts
Pathos
8 years ago
7
Topic

Hello,

i am trying to achieve that on a page where a search returns no items a other search is being performed and showen below the first search.

I have created a page with a search and it shows some text above the items. Now, when there are no items it should show the text (that works).

Below that i put a list module with a slightly different search. That works also...

But i want that module to only show when the first search is empty. Now its always there. And i have to do that not by linking the module to a menu-item or other trick.

What i was trying to do is the following:

create a variable in the view.html.php on the spot where the list-search is empty gets created. So when the result is empty the variable gets created. I'm no php coder so maybe i do something wrong. But this is how i think it could work..

$resultisempty = 1

Then i create a if statement in the template to only show the moduleposition if $resultisempty = 1 (or exists).

The problem is i can't seem to find the right spot to put this variable in view.html.php 

Or is this my whole approach wrong? :-)

Thanks for any pointers,

Joris

Get a Book for SEBLOD
187 Posts
Pathos
8 years ago
0
Level 1

I tried a lot of things. But can someone confirm that it is impossible to create a variable $variable = 1 in a seblod file or seblod template and then use that variable in a joomla-template?

It seems whatever i do the variable doesn't get recognized in my joomla-template. So i guess its not possible.

Greetings and thanks,

Joris

4229 Posts
Kadministrator
8 years ago
0
Level 1

Hi,

you can set Auto redirect to No, and then use no result  > action > file, and do redirect from that file that will get included to your second search. Take a look at this post for details

https://www.seblod.com/community/forums/forms-content-types/redirect-after-no-result

187 Posts
Pathos
8 years ago
1
Level 1

Hi Klas,

thank you for your reply. It did teach me a new thing but it didn't work for my special situation. I can add a redirect in that no_result file but thats not what i need. I need the module with the second search that is put beneath the content through my joomla-template to only show when the first search is empty.

Its kind like there are no users in city Paris, but here are some users near Paris. The search uses the one same parameter as the first search so it works to have two searches on 1 page. Exept that i dont want it to be displayed all the time.

I was able to put in a variabel lets say $emptylist = 1 in the no_result page. If i also echo $emptylist is can see the 1 appearing on the page.

But when i echo $emptylist in my joomla template it doesn't show a 1. So i guess its true that you can only use a variable within the boundries of the Seblod template or component. 

I tried using the code for the showing the module <jdoc:include type="modules" etc. in the no_result.php of seblod and that doesn't work either. The last thing i can imagine. But i thought a variable would be set for the whole rendering of the page.

Any ideas on that?

Thanks,

Joris

4229 Posts
Kadministrator
8 years ago
0
Level 2

You can only use variables within the scope, which is seblod component. You would need to set variable on joomla scope, e.g. in global registry or use session storage for that.

187 Posts
Pathos
8 years ago
1
Level 1

Hi Klas,

i thought it would be something like that. How can i do it through seblod and set a variable in global registry or session storage? I tried using BeforeRender but that didn't worked either. Maybe its a bit to difficult for me. Or maybe ist not possible at all like the way i want it to.

If i find a way i will let everybody know.

Thanks,

Joris

4229 Posts
Kadministrator
8 years ago
0
Level 2

You can set value in global configuration like this: JFactory::getConfig->set('variable', 'value'); you get it by

JFactory::getConfig->get('variable');

For session storage see e.g.

https://www.ostraining.com/blog/how-tos/development/how-to-use-sessions-in-joomla/

187 Posts
Pathos
8 years ago
0
Level 1

Hi Klas,

Yeahhhh

You send me in the right direction and with some fiddling i managed to get it done :-)

I used

JFactory::getConfig()->set('$myvariablename', 'whatmyvariableis');

This seemed to work when i used it on the templatepart.

So thanks a lot! Learned a lot trying to acclomplish it :-)

Get a Book for SEBLOD