• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Display inline
PostPosted: Tue Sep 10, 2019 6:01 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
Hey you all.
My module is almost working as I planned but I'm facing one unsolved problem.

I have a php file pointing to a template :
\$1:
<?php

if( !defined('CMS_VERSION') ) exit;

$query = new CategoryQuery;
$categorys = $query->GetMatches();

$sql = 'SELECT SQL_CALC_FOUND_ROWS H.* FROM '.CMS_DB_PREFIX.'mod_msfaq_questions H WHERE category = "'.$params['cname'].'" ORDER BY question';
$arr = $db->GetArray($sql);

$tpl = $smarty->CreateTemplate($this->GetTemplateResource('default.tpl'),null,null,$smarty);
$tpl->assign('questions',$arr);
$tpl->assign('categorys',$categorys);
$tpl->display();

?>


The template looks like this :
\$1:
<div class="msfaq_wrapper">
template
   <div id="categoryBlock">
      {foreach $categorys as $category}
         <div class="category">
            <div class="row">
               <div class="categoryline"><a href="{cms_action_url action='default' cname=$category->category_name}">{$category->category_name}</a>
               </div>
            </div>
         </div>
      {foreachelse}     
         <div class=”noquestions”>{$mod->Lang('noquestion')}</div>
      {/foreach}
   </div>
   
      <div id="questionAnswerBlock">
         {foreach from=$questions item=value}
         <div class="questionAnswer">
            <div class="question">{$value.question}</div>
            <div class="answer">{$value.answer}</div>
         </div>
      {/foreach}
   </div>
</div>


Now I want to click on a category and the result must be displayed on the place of the tag on the page. (Inline I think this is called).
Now when I click on the
\$1:
<div class="categoryline"><a href="{cms_action_url action='default' cname=$category->category_name}">{$category->category_name}</a>
and the module tag is on a separate div on a page, an new section is opend.

What code do I need to put in the php file or template to replace the module tag and not create a new section?

Please help.

TIA


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Wed Sep 11, 2019 2:01 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
Anyone ?

I'm building a module and want the replace the tag and not the page.

Please help

TIA


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Wed Sep 11, 2019 5:11 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7699
Location: The Netherlands
Did you try:
\$1:
<a href="{cms_action_url action='default' cname=$category->category_name}&showtemplate=false">{$category->category_name}</a>

_________________
$1

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Wed Sep 11, 2019 8:11 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8164
Location: Fernie British Columbia, Canada
The {cms_action_url} plugin does not support creating inline URL's. You would have to use the create_url() method of the module API and pass in the inline flag and assign the output from that method to a smarty variable.

That said.. I would recommend that you not use inline mode unless absolutely necessary as inline URLS cannot be pretty. and, I have found that it is counter intuitive. When you click on a link you largely expect that the content you have selected will appear in the prominent area of the page, not a sidebar etc. And 99% of the time the {content} block should represent the location where the primary information is displayed.

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Sat Sep 14, 2019 7:24 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
Calguy1000

Thank you for your answer.

What I did was create a website where all the pages are displayed on one page. I used the tips on cmscanbesimple.org.
https://cmscanbesimple.org/blog/multiple-pages-in-one-with-jquery-tabs
I used the CGSimpleSmarty module as mentioned in the tip.

On one of the pages I want to use my module to display faq's.
Clicking on a category should display the questions in that category.

But when I click on a category the template replaces the content tag meaning the questions are not opened in the section where the category's are displayed.

You can see the problem on my test website
[url]test.dev-infowebs.nl[/url]
Goto FAQ and click a category.

So I want the FAQ template to replace the faq-tag, not the content-tag

Please help


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Sat Sep 14, 2019 8:18 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8164
Location: Fernie British Columbia, Canada
Well, any link you generate will result in a page reload, and therefore a scroll. An inline link if you generated it properly using the create_url() method in the module API would generate the URL Properly, but would result in a page reload and a scroll.

In a single-page-app such as this you probably don't really want the thing to scroll every time you click something. I would just load the content via ajax. Which is pretty simple with jquery. The URL will not change, and there will be no scroll.

So if your category list template had:

<div id="mymodule">
{foreach $categories as $category}
<a href="{cms_action_url action='default' cname=$category->category_name}&showtemplate=false">{$category->category_name}</a>
{/foreach}
</div>

You could have a script section like (untested):
<__script__>
$(function(){
$('#mymodule a').click(function(ev){
ev.PreventDefault()
let href = $(this).attr('href')
$('#mymodule').load(href);
})
})
</__script>

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Sun Sep 15, 2019 9:55 am 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
Calguy1000

Thank you very much for this explanation.
I'm gonna try to use this jquery tip and let you know if was able to get it to work.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Wed Sep 18, 2019 2:52 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
I,m losing the battle. >:D

This is my template :
\$1:
<div class="msfaq_wrapper">

   <div id="categoryBlock">
      {foreach $categorys as $category}
         <div class="category">
            <div class="row">
               <div class="categoryline">
               <a href="{cms_action_url action='default' cname=$category->category_name}&showtemplate=false">{$category->category_name}</a>
               </div>
            </div>
         </div>
      {foreachelse}     
         <div class=”noquestions”>{$mod->Lang('noquestion')}</div>
      {/foreach}
   </div>
   
   <div id="questionAnswerBlock">
            Question Answer Test
      {foreach from=$questions item=value}
         <div class="questionAnswer">
            <div class="question">{$value.question}</div>
            <div class="answer">{$value.answer}</div>
         </div>
      {/foreach}
   </div>
</div>

And this is my php script :
\$1:
<?php

if( !defined('CMS_VERSION') ) exit;

$query = new CategoryQuery;
$categorys = $query->GetMatches();

$sql = 'SELECT SQL_CALC_FOUND_ROWS H.* FROM '.CMS_DB_PREFIX.'mod_msfaq_questions H WHERE category = "'.$params['cname'].'" ORDER BY question';
$arr = $db->GetArray($sql);

$tpl = $smarty->CreateTemplate($this->GetTemplateResource('default.tpl'),null,null,$smarty);
$tpl->assign('questions',$arr);
$tpl->assign('categorys',$categorys);
print_r($params);
$tpl->display();
?>


Here is my jquery script :

\$1:
$(function(){
   $('.categoryline a').click(function(ev){
   ev.PreventDefault();
   let href = $(this).attr('href');
   $('#faqmodule').load(href);
   })
})


When I click on a category, it opens a new page containing only the category's and the answers.

Test Here : http://test.dev-infowebs.nl/#faq

What is wrong in my code ?

I'm testing for over a week now, searching and searching what is wrong.

Please help.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Thu Sep 19, 2019 8:48 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7699
Location: The Netherlands
Looks to me your module *is* working, but it is a jQuery issue changing the content at that spot...

Great website by the way!!

_________________
$1

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Fri Sep 20, 2019 8:14 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3121
Location: The Netherlands
reload.js:

\$1:
$(function(){
   $('.categoryline a').click(function(ev){
   ev.preventDefault();
   let href = $(this).attr('href');
   $('#faqmodule').load(href);
   })
})


PreventDefault vs. preventDefault.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Display inline
PostPosted: Fri Sep 20, 2019 10:43 am 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
Thank you Calguy1000 en Velden.

I got it working :

To help others, here is my code :

action.default.php
\$1:
<?php

if( !defined('CMS_VERSION') ) exit;

$query = new CategoryQuery;
$categorys = $query->GetMatches();

$sql = 'SELECT SQL_CALC_FOUND_ROWS H.* FROM '.CMS_DB_PREFIX.'mod_msfaq_questions H WHERE category = "'.$params['cname'].'" ORDER BY question';
$arr = $db->GetArray($sql);

$tpl = $smarty->CreateTemplate($this->GetTemplateResource('default.tpl'),null,null,$smarty);
   
$tpl->assign('questions',$arr);
$tpl->assign('categorys',$categorys);
$tpl->display();

?>


default.tpl
\$1:
<div class="msfaq_wrapper">

   <div id="categoryBlock">
      {foreach $categorys as $category}
         <div class="category">
            <div class="row">
               <div class="categoryline">
               <a href="{cms_action_url action='default' cname=$category->category_name}&showtemplate=false">{$category->category_name}</a>
               </div>
            </div>
         </div>
      {foreachelse}     
         <div class=”noquestions”>{$mod->Lang('noquestion')}</div>
      {/foreach}
   </div>
   
   <div id="questionAnswerBlock">
            Question Answer Test
      {foreach from=$questions item=value}
         <div class="questionAnswer">
            <div class="question">{$value.question}</div>
            <div class="answer">{$value.answer}</div>
         </div>
      {/foreach}
   </div>
</div>

<__script__ src="assets/scripts/reload.js"></__script>


reload.js
\$1:
$(function(){
   $('.categoryline a').click(function(ev){
   ev.preventDefault();
   let href = $(this).attr('href');
   $('#faqmodule').load(href);
   })
})


Thank you guys. You are the best and you saved my day.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: [Solved] Display inline
PostPosted: Sun Sep 22, 2019 3:30 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 400
Location: Netherlands
It's working


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Hosting Nation - Managed CMSMS Hosting