Override widget

This topic contains 17 replies, has 4 voices, and was last updated by  Stiofan O’Connor 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #438415

    Pablo Bra
    Free User
    Post count: 10

    Hey,

    When modifying a theme In V2 RC, I tried to override widget and i thought that i just had to edit only one file but i noticed that one widget is spliced into many files:
    – content-widget-listing.php
    – content-listing.php
    – class-geodir-widget-post-images.php
    – etc…

    Is there a way to override widget that displays listing ?

    Thank you

    #438458

    Paolo
    Site Admin
    Post count: 31206

    Hi Pablo,

    you shouldn’t modify ANY file and use hooks.

    I asked to Stiofan to give you more details, it’d be useful to know what you are trying to achieve to give you better pointers…

    Thanks

    #438461

    Pablo Bra
    Free User
    Post count: 10

    Hey,
    Thank you for your reply
    I want to customize the output html of this widget:
    – GD> Listing: Best listings

    #438467

    Alex Rollin
    Moderator
    Post count: 27815

    Can you be more specific about how you want to modify the output?

    Like, are you trying to output a field label or value?

    #438503

    Pablo Bra
    Free User
    Post count: 10

    Hey,
    I want to modify the way listing cards are displayed
    – I want to use my html code instead of the outputed by GD> Listing: Best listings

    Make sense ?

    #438609

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I’m not 100% sure what u are trying to do, if you are trying to mod the actual listing output info (this can be done in the WP page “GD Archive Item”) or if you mean the surrounding wrappers and cat selectors?

    Stiofan

    #438624

    Pablo Bra
    Free User
    Post count: 10

    Hey
    Thank you for all your answers
    First of all im talking about V2 RC
    I can edit content-widget-listing.php and content-listing.php by copying them to the geodirectory folder of my theme.
    content-widget-listing.php calls content-listing.php the calls archive_item_template_content(); and i’m stuck here.

    I dropped the idea of overriding GD widget
    Im creating a widget to display listings, but I couldn’t find any GD api to grab raw content
    Example:

    <?php the_title(); ?>

    displays title without any html only text

    How can I call the content like address, category, rating stars…

    Please advice what is the best way to do this

    #438627

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    You can customise the output just by editing the page shortcodes.
    Go to WP>Pages>GD Archive Item>edit
    Then you can see a button that has 3 little squares, this will let you add more info, look for the GD psot meta, then u can select any meta info.

    Stiofan

    #438654

    Pablo Bra
    Free User
    Post count: 10

    Thank you
    Actually I’ve already tried the shortcode way
    But the shortcake displays all html, example here with title:

    When I use

    <?php echo do_shortcode("[gd_post_title]"); ?>

    I get this

    
    
    <div class="geodir-post-title">
      <h2 class="geodir-entry-title">
       <a href="http://localhost:8888/wp-listimia/places/alexander-inn/" title="View: Alexander    Inn">Alexander Inn</a>
      </h2>
    </div>

    It’s not about adding or removing elements, what I want is to change the layout:
    Add/rearrange html

    #438669

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    You can do everything u want without any php code or templates, we just need to know what u want 🙂 If you can explain that we can help more.

    Stiofan

    #438675

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I think the misunderstanding comes from you trying to work on the PHP templates, while Alex and Stiofan are suggesting that you use the shortcodes in the WordPress page assigned as “GD Archive Item”. (see image attached.)

    You can do everything with shortcodes and position any elements where you wish. At that point you don’t need to edit the HTML, you can simply add some custom CSS.

    Let us know how it goes,

    #438690

    Pablo Bra
    Free User
    Post count: 10

    Thank you guys
    Paolo, the problem is that i need to edit HTML to use my layout
    I can’t achieve what I want simply with CSS.

    As i told you im trying to create a theme so i need all this modifications in theme files.

    #438693

    Paolo
    Site Admin
    Post count: 31206

    You can programmatically change the shortcodes to be added to that page via functions.php of your theme. (Stiofan will tell you how asap)

    Than you can add the GD classes to your CSS to make them look like your theme custom classes. That way you don’t need to change the HTML at all.

    Otherwise you need to build your custom widgets from scratches. That will be a lot easier than trying to modify the plugin html output.

    We haven’t documented our custom PHP API for V2 but I think you can easily find all that you need by digging into the files that you wanted to modify.

    #438700

    Pablo Bra
    Free User
    Post count: 10

    Exact !
    As I told you I dropped the idea of overriding GD widget
    Im creating a custom widget to display listings, but I couldn’t find any GD api to grab raw content.
    Example:
    – <?php the_title(); ?> displays title without any html only text and this is what I want to achieve for other content.

    How can I call the content like address, category, rating stars… without any html ?

    #438702

    Paolo
    Site Admin
    Post count: 31206

    In V1 we used geodir_get_post_meta, example: https://wpgeodirectory.com/support/topic/custom-field-output/

    TBH I’m not 100% sure Stiofan kept the same API for V2. (He’ll confirm tomorrow as soon as he comes back online).

    If that returns any unwanted HTML you can remove it with PHP. http://php.net/manual/en/function.strip-tags.php

    Thanks for your patience,

Viewing 15 posts - 1 through 15 (of 18 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket