Jump to content

Recommended Posts

Hi everyone,

I'm trying to make some changes in ReadLess plugin in joomla. But I can't make that changes what I want. Maybe I don't know how. This plugin is make to cut intro text, cut title, and it can shows pictures for specified dimensions with links. And this plugin is only way to show my articles in my joomla site how I want. Problem with this plugin is that the people who make it, puts some lines in the code, and not registered people can't see the articles. It is allowed only for registered users. I want to both can see the articles. The original code is :

function _PopFirstImage( &$row, &$params, $page )
  {
    $firstImageHtml = '';

    if ( $this->params->get( 'moveFirstImage', true ) )
    {
      if ( preg_match( self::_imageTagPattern, $row->text, $matches ) > 0 )
      {
        $imageCode = $matches[0];
        $imageUrl = $matches[1];
      }
      if ( isset( $imageUrl ) )
      {
        $makeImageLinkToArticle = $this->params->get( 'makeImageLinkToArticle', true );
        if ( $makeImageLinkToArticle )
        {
          /* Guests who receive a different trailing text than registered users
           * may not see a linked image.
           */
          $user =& JFactory::getUser();
          if ( ( $user->guest == 1 )
              && ( JString::strlen( $this->params->get( 'trailingTextForGuests', '' ) ) > 0 ) )
          {
            $makeImageLinkToArticle = false;
          }
        }

        if ( $makeImageLinkToArticle )
        {
          $firstImageHtml .= '<a href="index.php?option=com_content&view=article&id='.$row->id.'">';
        }

        $attributes = self::_GetImageAttributes( $row->title );
        $firstImageHtml .= '<img src="' . $imageUrl. '"' . $attributes . '/>';

        if ( $makeImageLinkToArticle )
        {
          $firstImageHtml .= '</a>';
        }

        /* Remove the code for the image on the old location. */
        $start = JString::strpos( $row->text, $imageCode );
        $row->text = JString::substr_replace( $row->text, '', $start, JString::strlen( $imageCode ) );
      }
      else
      {
        /* No image was found. There is no image to move in front of the article.
         * Nothing to do.
         */
      }
    }
    else
    {
      /* Don't hunt for an image, don't move it first in the article.
       * Nothing to do.
       */
    }

    return $firstImageHtml;
  }

I've made some changes in some lines, and it looks like this :

function _PopFirstImage( &$row, &$params, $page )
  {
    $firstImageHtml = '';

    if ( $this->params->get( 'moveFirstImage', true ) )
    {
      if ( preg_match( self::_imageTagPattern, $row->text, $matches ) > 0 )
      {
        $imageCode = $matches[0];
        $imageUrl = $matches[1];
      }
      if ( isset( $imageUrl ) )
      {
        $makeImageLinkToArticle = $this->params->get( 'makeImageLinkToArticle', true );
        if ( $makeImageLinkToArticle )
        {
          /* Guests who receive a different trailing text than registered users
           * may not see a linked image.
           */
          $user =& JFactory::getUser();
          if ( ( $user->guest == 0 ) && ( JString::strlen( $this->params->get( 'trailingTextForGuests', '' ) ) > 1 ) )
          {
	  	if (( $user->guest == 1 ) && ( JString::strlen( $this->params->get( 'trailingTextForGuests', '' ) ) > 0 ))
		{
            $makeImageLinkToArticle = false;
		}
          }
        }

        if ( $makeImageLinkToArticle )
        {
          $firstImageHtml .= '<a href="index.php?option=com_content&view=article&id='.$row->id.'">';
        }

        $attributes = self::_GetImageAttributes( $row->title );
        $firstImageHtml .= '<img src="' . $imageUrl. '"' . $attributes . '/>';

        if ( $makeImageLinkToArticle )
        {
          $firstImageHtml .= '</a>';
        }

        /* Remove the code for the image on the old location. */
        $start = JString::strpos( $row->text, $imageCode );
        $row->text = JString::substr_replace( $row->text, '', $start, JString::strlen( $imageCode ) );
      }
      else
      {
        /* No image was found. There is no image to move in front of the article.
         * Nothing to do.
         */
      }
    }
    else
    {
      /* Don't hunt for an image, don't move it first in the article.
       * Nothing to do.
       */
    }

    return $firstImageHtml;
  }

I've got the results what I want, but they aren't completely. I've got problems with URLs.

So, is any solution for this code? Can I make to all users can see the articles, not only registered ? With my changes I've got the solution, but I still have problem with URLs. Some solution please ??

Link to comment
https://forums.phpfreaks.com/topic/217433-joomla-plugin-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.