Announcement

Collapse
No announcement yet.

Search Widget Conditionals

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Search Widget Conditionals

    I'm trying to do a modification to Template display_contenttype_searchwidget_item_footer
    Right now, on my homepage I have a preview of articles and latest forum activity in the left and center column of a three column page. In the footer for each, I'm trying to add the age of these but conditionally as to which age appears...

    For topics, I'd like to show the last post date/time, but for articles, I want to only show the created time (not edits or comments)

    Is there an easy way to do this in a conditional? I've tried a few different ideas, but can't land on something that would identify the search result as an article vs a topic.

    Code:
      <vb:if condition="  (this is a topic ) ">
      Last Activity: {vb:datetime {vb:raw conversation.lastcontent}}
      <vb:else />
      {vb:datetime {vb:raw conversation.created}}
      </vb:if>​

    #2
    Try to vardump the conversation variable to compare the values between forum topic and article topic and see which one identifies the post.

    Code:
    {vb:debugvardump conversation}
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      Good suggestion... the $conversation['channelid'] is easy enough to filter on:

      Code:
      <vb:if condition="$conversation['channelid'] == '2283317' OR
      $conversation['channelid'] == '1283324' OR
      $conversation['channelid'] == '1283325' OR
      $conversation['channelid'] == '1283323' OR
      $conversation['channelid'] == '1283321' OR
      $conversation['channelid'] == '1283322'">
      Posted {vb:datetime {vb:raw conversation.created}}
      <vb:else />
      Last Activity: {vb:datetime {vb:raw conversation.lastcontent}}
      </vb:if>​
      I'd initially looked into RouteID but getting the Channel ID from the Channel Manager is easier to manage.

      Comment


        #4
        The finished product:

        Click image for larger version

Name:	capture_400778.jpg
Views:	40
Size:	121.8 KB
ID:	28463

        Comment


          #5
          Originally posted by Eolesen View Post
          Good suggestion... the $conversation['channelid'] is easy enough to filter on:

          Code:
          <vb:if condition="$conversation['channelid'] == '2283317' OR
          $conversation['channelid'] == '1283324' OR
          $conversation['channelid'] == '1283325' OR
          $conversation['channelid'] == '1283323' OR
          $conversation['channelid'] == '1283321' OR
          $conversation['channelid'] == '1283322'">
          Posted {vb:datetime {vb:raw conversation.created}}
          <vb:else />
          Last Activity: {vb:datetime {vb:raw conversation.lastcontent}}
          </vb:if>​
          I'd initially looked into RouteID but getting the Channel ID from the Channel Manager is easier to manage.
          Nice!

          You can also simplify the code to:

          Code:
          <vb:if condition="in_array($conversation['channelid'], array('2283317', 1283324', '1283325', '1283323', '1283321', '1283322'))">​
              Posted {vb:datetime {vb:raw conversation.created}}
          <vb:else />
              Last Activity: {vb:datetime {vb:raw conversation.lastcontent}}​
          </vb:if>
          Helpful? Donate. Thanks!
          Buy me a coffeePayPal QR Code
          Fast VPS Host for vBulletin:
          A2 Hosting & IONOS

          Comment


            #6
            Showoff. I'm still figuring out template coding capabilities. If there were a way to use a db query to pull the article channel IDs, I'd do that vs a hard-coded array, but your way is definitely cleaner.

            Comment


              #7
              Create a custom API and then call it from the template.
              Helpful? Donate. Thanks!
              Buy me a coffeePayPal QR Code
              Fast VPS Host for vBulletin:
              A2 Hosting & IONOS

              Comment

              Users Viewing This Page

              Collapse

              There is 1 user viewing this forum topic.

              • Guest Guest

              Latest Posts

              Collapse

              Working...
              X
              Searching...Please wait.
              An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

              Please push the back button and reload the previous window.'
              An unexpected error was returned: 'Your submission could not be processed because the token has expired.

              Please push the back button and reload the previous window.'
              An internal error has occurred and the module cannot be displayed.
              There are no results that meet this criteria.
              Search Result for "|||"