-1

I think I need your help here... On my site, I've done all the articles open in modal window by clicking on the link "read more" that exists in every article.

Also, each article has a button that shares this article on facebook.

But, when the user who will see my article on facebook, click this link to read the article, it come back to my page, but the article (logical) not open in modal window!!!

Is there any way, in the "return" of the user on my site, after having pressed the link of facebook, automatically open this article in modal window? Or, if the question above can't be done, is there any way by customizing the link I send to facebook, to set it in the "return" of the user to my site, after having pressed the facebook's link ofcourse, to show the article in intro view and not in full view?

Thank you very much for your time!

DNA180
  • 266
  • 1
  • 7
  • 28
  • I'm not sure I follow what you want to do. Is it that when user arrives to your website/article from Facebook, an article will open in modal box? – piotr_cz Mar 23 '13 at 16:57
  • Yes! Take a look on the solution I added below and tell me your opinion. The accepted one, with the tick. – DNA180 Mar 23 '13 at 17:29

2 Answers2

1

I'm using modal windows in my website and I utilize the following HTML code to open an article in a popup:

<a class="modal" rel="{handler: 'iframe', size: {x: 680, y: 370}}" href="yourarticleid=759&tmpl=component&task=preview">Open a link in modal</a>

The method above uses the native function for creating the modal window and calls the article you need to display. However, since Facebook formats all posted links I don't think you'll be able to include the crucial piece of code (below) that triggers the modal window.

class="modal" rel="{handler: 'iframe', size: {x: 680, y: 370}}"
otinanai
  • 3,987
  • 3
  • 25
  • 43
  • I though so... What about the second idea? There is any way my articles to open in intro view and not in full view? Thank you for your answer and your time! – DNA180 Mar 15 '13 at 15:03
  • Did you try splitting your articles first? Here's a very good documentation for splitting your article into an intro text with Read more button: http://docs.joomla.org/Splitting_an_Article_into_an_introduction_with_a_link_to_read_more – otinanai Mar 15 '13 at 15:35
  • Yes I have done this. In frontend my article show only first part. Intro I mean. But when someone click on facebook's link takes the whole article!!! – DNA180 Mar 15 '13 at 15:38
  • I haven't tried to do something similar before but let's see the facts: 1. Read more links are only visible to category blog layouts. 2. Intro text is only displayed in category blog layout 3. CONCLUSION: Instead of having a link to display the article, create a link with category blog layout and use CSS or any backend solution to hide the rest of the articles that are included in this category. This is just a thought of mine that will work in theory but it doesn't give you flexibility on having dynamic links for each article, meaning that you have to create each link manually. – otinanai Mar 15 '13 at 15:51
  • I'll try some things I have in mind, plus yours, and we will see what will happen at the end!!! :) – DNA180 Mar 15 '13 at 15:57
  • 1
    In the meantime I'm trying to find a more global solution because it'd be nice to have it for future use. – otinanai Mar 15 '13 at 16:06
  • exactly! ..or "whatever" in free translation. :D – otinanai Mar 15 '13 at 16:20
  • 2
    Brother take a look on acceptable answer below I think you may need something like this!!! ;) – DNA180 Mar 23 '13 at 16:22
1

Here is a kind of solution, an idea in other words, that make your articles open in modal window, after a user click on facebook share link and then come back to your site.

In my case I did this...

To open modal windows in my site, I am using the extension modalizer from nonumber.nl. This extension adds something like that &ml=1 at the end of article's url. The link that comes from facebook don't contain this &ml=1 at the end. So...

1. First of all, in to my article's content, I should include modal's behavior.

2. Then, I should make my code check if the url has this &ml=1 at the end or not.

3. After, I should decide what my code will do in those two cases. So, I want to do nothing if &ml=1 already exists and I want to open facebook's url in modal window if &ml=1 doesn't exist. I also want everytime that I close my modal window to load index.php, else user will see my article on frontend view.

Here is the code for all this:

<?php JHTML::_('behavior.modal'); 

      $url= 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  if (strstr($url, "&ml=1")){/* Do nothing */} 
else {?> <a class="modal" id="modalWindowLink" href="<?php echo $url ?>"></a>
         <script>
         window.addEvent('domready', function(){
         window.addEvent('load', function(){ SqueezeBox.fromElement($('modalWindowLink')); });
     });

         SqueezeBox.addEvent('onClose', function(){ window.location = 'index.php'; });
         </script>
     }
     <?php } ?>

If you have any better idea, or if you see something that could work better in other way, please let me know!!!

DNA180
  • 266
  • 1
  • 7
  • 28
  • 1
    I think you are on the right track. I'd just streamline the code a bit: `$url = JUri::getInstance(); if (!$url->getVar('ml')) { JFactory::getDocument()->addScript( "SqueezeBox.open( $('wrapper') )" ); }`. BTW Joomla 1.5 is really outdated - you should upgrade to 2.5+ at least for sake of security – piotr_cz Mar 23 '13 at 19:29
  • I know my friend you are right but believe me, I don't really have the necessary time to upgrade this specific site!!! It has so many custom stuff in there, that it could take me much much time to do that and I haven't it... Maybe next year!!! Thank you for your time and everything!!! :) – DNA180 Mar 23 '13 at 20:16
  • 1
    I forgot to add in comment above: `SqueezeBox.open...` should be wrapped in `document.addEvent('domready', function() { SqueezeBox.open... })`. and `wrapper` is an id of element that holds the content (default in Beez template) that you want to show in modal window. – piotr_cz Mar 24 '13 at 17:53