Custom field
« on: December 27, 2023, 12:30:46 PM »
I would like to display my custom field in the side bar, how do I do that? the field is called article number.


I thank you in advance for the help.

Marked as best answer by Roberto Klapper on January 02, 2024, 02:08:39 PM
*

MB Themes

Re: Custom field
« Reply #1 on: December 30, 2023, 09:10:39 PM »
There is checkbox to add field into search.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #2 on: January 02, 2024, 02:10:09 PM »
I would like to have the field as PHP code so that I can put it where I want it.

*

MB Themes

Re: Custom field
« Reply #3 on: January 02, 2024, 06:27:28 PM »
That might be quite hard with custom fields.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #4 on: January 03, 2024, 10:33:03 AM »
I know it can be difficult.


Is it the code? How do I then add the artikel-nummer- field that only shows the number that I saved before?
Code: [Select]
osc_item_meta_name()
« Last Edit: January 03, 2024, 05:22:05 PM by Roberto Klapper »

*

MB Themes

Re: Custom field
« Reply #5 on: January 03, 2024, 08:05:24 PM »
You need to loop, best to pick existing code from item.php and customize it.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #6 on: January 04, 2024, 11:39:58 AM »
It would be this code in item.php

Code: [Select]
<?php if( osc_count_item_meta() >= ) { ?>
      <div id="custom_fields">
        <div class="meta_list">
          <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_value()!='') { ?>
              <div class="meta">
                <strong><?php echo osc_item_meta_name(); ?>:</strong> <span><?php echo osc_item_meta_value(); ?></span>
              </div>
            <?php ?>
          <?php ?>
        </div>
      </div>
    <?php ?>

I want to grab him for it. But somehow it doesn't work.

Code: [Select]
<style>
             
             @media print {
#print {
     display:flex;
     justify-content:center;
     align-items:center;
     height:100%;
     margin: 0 auto;
     vertical-align: text-top;
     position: relative;
     top: 40px; left: 40px;
     }
             
          .centered {
  position: relative;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%);
}
          </style>
         
          <script>
             
        function printDiv(print){
              var restorepage = document.body.innerHTML;
              var printcontent = document.getElementById('print').innerHTML;

              document.body.innerHTML = printcontent;
                 
              window.print();
                 
              document.body.innerHTML = restorepage;

}
</script>
         
          <details>
          <summary><h1></h1></summary><button onclick="printDiv('print')">Print</button><div id='print'>
             
              <p><center><div><h1><?php echo osc_item_category() ; ?></h1></div></center></p>
              <p style="line-height: 150%"><center><div><font size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;"><?php echo osc_item_title(); ?></font></div></center></p>
              <p></p>
              <p style="line-height: 150%" class="centered"><center><div><p><span><font  size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;text-align: end; position: relative;"><?php echo osc_item_formated_price(); ?></font></span></p></div></center></p><br>
              </div>
</details>

*

MB Themes

Re: Custom field
« Reply #7 on: January 04, 2024, 06:23:02 PM »
Yes that code is correct. Maybe I would add at start reset/get to make sure you have good data
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #8 on: January 05, 2024, 10:33:58 AM »
I've done it like this now, but I have three custom fields but I only want to display the one, which is the artikel-nummer- so how do I do that? Oh yes and maybe someone can tell me why I can't print using Chrome? It works with other browsers.


Code: [Select]
      <style>
             
             @media print {
#print {
     display:flex;
     justify-content:center;
     align-items:center;
     height:100%;
     margin: 0 auto;
     vertical-align: text-top;
     position: relative;
     top: 40px; left: 40px;
     }
             
          .centered {
  position: relative;
  top: 80%;
  left: 50%;
  transform: translate(-50%, -50%);
}
          </style>
         
          <script>
             
        function printDiv(print){
              var restorepage = document.body.innerHTML;
              var printcontent = document.getElementById('print').innerHTML;

              document.body.innerHTML = printcontent;
                 
              window.print();
                 
              document.body.innerHTML = restorepage;

}
</script>
         
          <details>
          <summary><h1></h1></summary><button onclick="printDiv('print')">Print</button><div id='print'>
             
              <p><center><div><h1><?php echo osc_item_category() ; ?></h1></div></center></p>
              <p style="line-height: 150%"><center><div><font size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;"><?php echo osc_item_title(); ?></font></div></center></p>
              <p></p>
              <p style="line-height: 150%" class="centered"><center><div><p><span><font  size="5" style="display:table-cell; vertical-align:middle; font-weight:bold;text-align: end; position: relative;"><?php echo osc_item_formated_price(); ?></font></span></p></div></center></p><br><?php if( osc_count_item_meta() >= ) { ?>
      <div id="custom_fields">
        <div class="meta_list">
          <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_value()!='') { ?>
              <div class="meta">
                <strong><?php echo osc_item_meta_name(); ?>:</strong> <span><?php echo osc_item_meta_value(); ?></span>
              </div>
            <?php ?>
          <?php ?>
        </div>
      </div>
    <?php ?>
              </div>
</details>

*

MB Themes

Re: Custom field
« Reply #9 on: January 05, 2024, 02:45:40 PM »
Code: [Select]
if(id == 'articel number id') {
 ...
}
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #10 on: January 05, 2024, 05:28:35 PM »

So I replace this code
Code: [Select]
<?php if(osc_item_meta_value()!='') { ?>

With these. Did I understand that correctly? I'm not that familiar with PHP.
Code: [Select]
<?php if(id == 'articel number id') { ?>         

*

MB Themes

Re: Custom field
« Reply #11 on: January 06, 2024, 09:24:55 AM »
No.
If you have absolutely no idea about php, does not make sense to ask for helps, as help for you means someone will prepare for you complete solution that is not point of this forums.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #12 on: January 08, 2024, 11:37:39 AM »
I did not mean it like that


I did it that way, but if I only want to have one field and not the whole list, what do I have to change? I basically have three custom fields but only want one to be displayed in this area.
Code: [Select]
<?php if( osc_count_item_meta() >= ) { ?>
      <div id="custom_fields">
        <div class="meta_list">
          <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_value()!='artikel-nummer-') { ?>
              <div class="meta">
                <strong><?php echo osc_item_meta_name(); ?>:</strong> <span><?php echo osc_item_meta_value(); ?></span>
              </div>
            <?php ?>
          <?php ?>
        </div>
      </div>
    <?php ?>

*

MB Themes

Re: Custom field
« Reply #13 on: January 08, 2024, 01:05:43 PM »
So why you do not uodate that condition so it match only field you want?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Custom field
« Reply #14 on: January 08, 2024, 01:18:54 PM »
what do you mean exactly? So in the print version I only need the artikel-nummer-. On the normal item page the three fields can remain.